dxdy = ((1, 0), (0, 1), (0, 1), (-1, 0), (0, -1), (0, -1)) ABC = ('a', 'b', 'c') s = input() st = set([(0, 0)]) t = 0 x, y = 0, 0 for c in s: k = ABC.index(c) * 2 + t dx, dy = dxdy[k % 6] x += dx y += dy st.add((x, y)) t += 3 t %= 6 print(len(st))