eolymp
bolt
Try our new interface for solving problems
Problems

Challenging tasks

Challenging tasks

Yesterday Tosha came to the programming olympiad for the first time, and wanted to shout because of the complexity of the problems. However, it is forbidden to make noise at the contest, so Tosha shouted on paper. Namely, in the process of solving the problem, he from time to time wrote the letters "A" in the drafts. The more difficult task is, the more letters "A" Tosha wrote in the process of solving it.

The next day, Tosha wanted to brag to his classmates that he was solving an Olympiad, in which there were so many problems. But it was not possible to see how many problems there were - instead of the conditions Tosha took the drafts from the contest.

Fortunately, all the other entries, except for the letters "A", which he wrote, horrified at the complexity of the problems, Tosha made in lowercase letters. Tosha also remembers that all the problems were of different non-zero complexity, which means that in the process of solving different problems he wrote a different number of letters "A" in the drafts. Moreover, between the letters "A", written while solving one problem, he could make other entries in lowercase letters.

Help Tosha by his notes in the drafts to understand what is the maximum number of problems could be in the contest.

Input

One non-empty line s - the entry in Tosha's draft. The string length does not exceed 106. The string consists of lowercase Latin letters and uppercase Latin letters "A" and contains at least one uppercase "A".

Output

Print an integer - the maximum number of problems that could be in the contest.

Time limit 1 second
Memory limit 128 MiB
Input example #1
dfsAAfftaAbcdAAtoshaAtoAApA
Output example #1
3
Source 2018, XXVI Командный чемпионат школьников Санкт-Петербурга по программированию, October 18, Problem E