#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define int long long #define double long double typedef vector VI; typedef pair pii; typedef vector VP; typedef vector VS; typedef priority_queue PQ; templatebool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } #define fore(i,a) for(auto &i:a) #define REP(i,n) for(int i=0;i, greater > q2; signed main() { cin.tie(0); ios::sync_with_stdio(false); string S; cin >> S; int N = S.size(); VI A(N); REP(i, N) { if (S[i] == 'a')A[i] = 0; if (S[i] == 'b')A[i] = 1; if (S[i] == 'c')A[i] = 2; } int ans = 0; mapmp; int x = 0, y = 0; //int type[3] = { 0,1,2 };//その記号がどの移動に対応するか VI type = { 0,1,2 }; mp[(pii) { x, y }] = 1; REP(i, N) { int t = type[A[i]]; VI tmp(3); if (t == 0) { x--; REP(j, 3) { type[j]++; type[j] %= 3; } } else if (t == 1) { x++; REP(j, 3) { type[j]--; type[j] += 3; type[j] %= 3; } } else { if (y % 2) { y--; } else { y++; } } if (!mp[(pii) { x, y }]) { ans++; mp[(pii) { x, y }] = 1; } //cout << x << " " << y << endl; } cout << ++ans << endl; return 0; }