There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
n = input()
s=""
for i in range(len(n)):
    if(n[i]=="B" and s != ""):
        s=s[:-1]
    else:
        s+=n[i]
print(s)
        

n = int(input())
ans = 0
for i in range(n):
    ans += i+1
print(ans)