#include using namespace std; int main() { string S; cin >> S; set> SE; SE.insert({0, 0}); for (int i = 0, f = 0, a = 0, b = 1, c = 2, x = 0, y = 0, t; i < S.size(); i++, f ^= 1) { if (S[i] == 'a') (f) ? SE.insert({x, ++y}) : SE.insert({x, --y}); if (S[i] == 'b') SE.insert({--x, y}), t = a, a = c, c = b, b = t; if (S[i] == 'c') SE.insert({++x, y}), t = a, a = b, b = c, c = t; } cout << SE.size() << "\n"; }