Life in Innopolis

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

INNOPOLIS  ˜TIMES\mathbb{INNOPOLIS} \~ \mathbb{TIMES}

December, 18, 2016


Is there life in Innopolis?


Life in Innopolis could have been brought by space body. That's a conclusion made by a scientist after examining the consistency of water taken from this area: strange DNA structure interested him. Research would take years...

To speed up the process of research, he turned to you. Let's represent DNA as a string ss, consisting of four uppercase letters, one for each nucleotide: "A", "C", "G" and "T". Scientist has only one question: for how many positions ii suffix starting at position ii is lexicographically less than suffix starting at position i+1i + 1.

Suffix is a sequence of consecutive characters, ending with the last character of the string. String itself is also its suffix. For example, ACGC, CGC, GC, and C are all suffixes of string ACGC.

String aa is lexicographically less than string bb, if there is such kk that first kk characters of aa and bb coincide and a_k+1<b_k+1a\_{k+1} < b\_{k+1}, or if aa is shorter than bb and a_i=b_ia\_i = b\_i for all iai \le |a|. For example, "A" < "G", "AAG" < "AAT", "AGC" < "AGCA".

입력

Input contains a single string ss, consisting of uppercase letters of Latin alphabet: "A", "C", "G" and "T". 

String length doesn't exceed 3,000,0003\\,000\\,000.

출력

Output a single integer --- number of positions ii such that suffix starting at ii is lexicographically less than suffix starting at position i+1i + 1.

힌트

There are three such positions in the first example:

  1. i=1i=1: "ACGACA" < "CGACA"
  2. i=2i=2: "CGACA" < "GACA"
  3. i=4i=4: "ACA" < "CA"

And only two positions in the second one:

  1. i=1i=1: "AATTAA" < "ATTAA"
  2. i=2i=2: "ATTAA" < "TTAA"