#include #include #include #include #include #include #include #include using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); }; } fio; signed main(){ cout<,int>> S; string s; cin>>s; S.insert({{x,y},z}); for(int i = 0; i < s.size(); i++){ int temp = ((y - x) % 3 + 3) % 3; if(temp == 0) { if(!z) { if(s[i] == 'a') x--; // if(s[i] == 'b') z++; if(s[i] == 'c') y--; } else { if(s[i] == 'a') y++; // if(s[i] == 'b') z--; if(s[i] == 'c') x++; } } else if(temp == 1) { if(!z) { if(s[i] == 'b') x--; // if(s[i] == 'c') z++; if(s[i] == 'a') y--; } else { if(s[i] == 'b') y++; // if(s[i] == 'c') z--; if(s[i] == 'a') x++; } } else if(temp == 2) { if(!z) { if(s[i] == 'c') x--; // if(s[i] == 'a') z++; if(s[i] == 'b') y--; } else { if(s[i] == 'c') y++; // if(s[i] == 'a') z--; if(s[i] == 'b') x++; } } z = !z; S.insert({{x,y},z}); // cout<