#include #include #include #include #include #include #include #include #include #include using namespace std; typedef pair P; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); string S; cin >> S; set

s; s.insert(P(0, 0)); int flag = 0; vector vec(3); vec[0] = 3, vec[1] = 2, vec[0] = 1; int x = 0, y = 0; for(int i = 0; i < S.size(); i++){ if(flag == 0){ flag = 1; if(vec[S[i] - 'a'] == 3){ x += 3; y += 4; for(int j = 0; j < 3; j++){ if(vec[j] == 1) vec[j] = 3; else if(vec[j] == 2) vec[j] = 1; else vec[j] = 2; } } else if(vec[S[i] - 'a'] == 2){ x -= 3; y += 4; for(int j = 0; j < 3; j++){ if(vec[j] == 1) vec[j] = 2; else if(vec[j] == 2) vec[j] = 3; else vec[j] = 1; } } else{ y -= 5; } } else{ flag = 0; if(vec[S[i] - 'a'] == 3){ x += 3; y -= 4; for(int j = 0; j < 3; j++){ if(vec[j] == 1) vec[j] = 3; else if(vec[j] == 2) vec[j] = 1; else vec[j] = 2; } } else if(vec[S[i] - 'a'] == 2){ x -= 3; y -= 4; for(int j = 0; j < 3; j++){ if(vec[j] == 1) vec[j] = 2; else if(vec[j] == 2) vec[j] = 3; else vec[j] = 1; } } else{ y += 5; } } s.insert(P(x, y)); } cout << s.size() << endl; }