#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; #define REP(i,n) for(int i=0;i> s; int n=s.size(); set> st; st.insert({0,0}); string p0[3]={"abc","bca","cab"}; string p1[3]={"cab","abc","bca"}; int x=0, y=0; REP(i,n){ int p=((y+600000)/2+x*2+600000)%3; if(y%2==0){ if(s[i]==p0[p][0]) y++; else if(s[i]==p0[p][1]) y--; else y++,x--; } else{ if(s[i]==p1[p][0]) y++; else if(s[i]==p1[p][1]) y--; else y--,x++; } //cout << x << ' ' << y << endl; //cout << st.count({x,y}) << endl; st.insert({x,y}); } cout << st.size() << endl; return 0; }