from collections import deque

s = input()

q = deque()
q.append(s)
c = []
c.append(s)

a = 1
p = 1000000007
L = len(s) - 1
while q:
    x = q.popleft()
    l = len(x)
    if L == l:
        L -= 1
        c = []
    for i in range(l-1):
        if x[i] == "a" and x[i+1] == "a":
            t = x[:i] + "b" + x[i+2:]
            w = True
            for j in c:
                if t == j:
                    w = False
                    break
            if w:
                q.append(t)
                c.append(t)
                a += 1
        elif x[i] == "b" and x[i+1] == "b":
            t = x[:i] + "a" + x[i+2:]
            w = True
            for j in c:
                if t == j:
                    w = False
                    break
            if w:
                q.append(t)
                c.append(t)
                a += 1
        if a == p:
            a = 0

print(a)
