#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++) #define chmin(x, y) (x) = min((x), (y)) #define chmax(x, y) (x) = max((x), (y)) #define all(x) (x).begin(),(x).end() #define inf 1e18 using namespace std; typedef long long llint; typedef long long ll; typedef pair P; 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) { ios::sync_with_stdio(0); cin.tie(0); cin >> s; ll x = 0, y = 0; S.insert(P(0, 0)); for(auto c : s) move(x, y, c), S.insert(P(x, y)); cout << (int)S.size() << endl; return 0; }