#include using namespace std; typedef long long ll; typedef long double ld; #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define FORR(i, m, n) for (int i = m; i >= n; --i) #define ALL(v) (v).begin(),(v).end() templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b d[2][3]={{{-1,0},{1,0},{0,-1}},{{-1,0},{1,0},{0,1}}}; int main(){ cin.tie(0); ios::sync_with_stdio(false); string s;cin >> s; map,int> mp; int x=0,y=0; mp[{x,y}]++; int n=s.size(); int ans=0; vector c(3); REP(i,3) c[i]=i; REP(i,n){ REP(j,3){ if(s[i]-'a'==c[j]){ x+=d[i%2][j].first,y+=d[i%2][j].second; mp[{x,y}]++; if(j==0){ int tmp[]={c[2],c[0],c[1]}; REP(k,3) c[k]=tmp[k]; } else if(j==1){ int tmp[]={c[1],c[2],c[0]}; REP(k,3) c[k]=tmp[k]; } break; } } } cout << mp.size() << endl; }