#include #include using namespace std; int main(){ string s;cin>>s; pair nw = {0,0}; set> A; A.insert(nw); for(int i = 0; s.size() > i; i++){ if(i%2){ if(s[i] == 'a')nw.second--; else if(s[i] == 'b')nw.first++; else nw.second++; }else{ if(s[i] == 'a')nw.second++; else if(s[i] == 'b')nw.first--; else nw.second--; } A.insert(nw); } cout << A.size() << endl; }