#include using namespace std; //#include //using namespace atcoder; template bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; } template bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; } #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) //#define endl "\n" typedef pair P; const ll INF = 1e18; //using mint = modint1000000007; //using mint = modint998244353; //const int INF=INT_MAX; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll lcm(ll a, ll b){return a * b / gcd(a, b);} //写し string s; set

S; void move(ll &x, ll &y, char c) { ll p = ((x+3*y) % 6 + 6) % 6; if(c == 'b') p += 2, p %= 6; if(c == 'c') p += 4, p %= 6; if(p == 0) x--; if(p == 1) y++; if(p == 2) x++; if(p == 3) x--; if(p == 4) y--; if(p == 5) x++; } int main(void) { cin >> s; ll x = 0, y = 0; S.emplace(0,0); for(auto c : s) move(x, y, c), S.insert(P(x, y)); cout << (int)S.size() << endl; return 0; }