#include using namespace std; template bool cmin(T &a, U b) { return a > b && (a = b, true); } template bool cmax(T &a, U b) { return a < b && (a = b, true); } signed main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); string S; cin >> S; int N = S.size(); set> SE; SE.insert({0, 0}); for (int i = 0, f = 0, a = 0, b = 1, c = 2, x = 0, y = 0; i < N; i++) { int now = S.at(i) - 'a'; if (f) { if (now == a) { SE.insert({x, --y}); } else if (now == b) { SE.insert({--x, y}); int tmp = a; a = c; c = b; b = tmp; } else { SE.insert({++x, y}); int tmp = a; a = b; b = c; c = tmp; } f = 0; } else { if (now == a) { SE.insert({x, ++y}); } else if (now == b) { SE.insert({--x, y}); int tmp = a; a = c; c = b; b = tmp; } else { SE.insert({++x, y}); int tmp = a; a = b; b = c; c = tmp; } f = 1; } } cout << SE.size() << "\n"; }