#include using namespace std; int main(){ string S; cin >> S; set> pos; int x = 0; int y = 0; pos.insert(make_pair(x, y)); int N = S.size(); for (int i = 0; i < N; i++){ int X = x % 6; if (X < 0){ X += 6; } int Y = y % 2; if (Y < 0){ Y += 2; } if (S[i] == 'a'){ if (Y == 0){ if (X == 0){ x++; } else if (X == 1){ x--; } else if (X == 2){ y--; } else if (X == 3){ x++; } else if (X == 4){ x--; } else if (X == 5){ y++; } } else { if (X == 0){ x++; } else if (X == 1){ x--; } else if (X == 2){ y++; } else if (X == 3){ x++; } else if (X == 4){ x--; } else if (X == 5){ y--; } } } if (S[i] == 'b'){ if (Y == 0){ if (X == 0){ y--; } else if (X == 1){ x++; } else if (X == 2){ x--; } else if (X == 3){ y++; } else if (X == 4){ x++; } else if (X == 5){ x--; } } else { if (X == 0){ y++; } else if (X == 1){ x++; } else if (X == 2){ x--; } else if (X == 3){ y--; } else if (X == 4){ x++; } else if (X == 5){ x--; } } } if (S[i] == 'c'){ if (Y == 0){ if (X == 0){ x--; } else if (X == 1){ y++; } else if (X == 2){ x++; } else if (X == 3){ x--; } else if (X == 4){ y--; } else if (X == 5){ x++; } } else { if (X == 0){ x--; } else if (X == 1){ y--; } else if (X == 2){ x++; } else if (X == 3){ x--; } else if (X == 4){ y++; } else if (X == 5){ x++; } } } pos.insert(make_pair(x, y)); } cerr << "x = " << x << ", y = " << y << endl; cout << pos.size() << endl; }