K-Inversions

For every distance k, count pairs (i,j) with i<j, s[i]='B', s[j]='A', and j-i=k, over a string of up to a million characters.

Medium7Divide and conquerStringImplementationMathNo attempts yetTime limit10sMemory limit512 MB

Problem

You are given a string ss made only of the upper case letters A and B. Let nn be its length. For an integer kk, a pair of indices (i,j)(i, j) is a kk-inversion when 1i<jn1 \le i < j \le n, s[i]=Bs[i] = \text{B}, s[j]=As[j] = \text{A}, and ji=kj - i = k.

Take the string BABA. It has two 1-inversions and one 3-inversion, and it has no 2-inversions.

For each kk from 11 to n1n - 1, report the number of kk-inversions in ss.

Input

The first line contains the string ss. It consists only of the upper case letters A and B, with no spaces. Its length nn satisfies 1n10000001 \le n \le 1\,000\,000.

Output

Print n1n - 1 lines, each with one integer. The first line holds the number of 1-inversions, the second line the number of 2-inversions, and so on up to the number of (n1)(n - 1)-inversions. When n=1n = 1, print nothing.