#include "bits/stdc++.h" #define MOD 1000000007 #define rep(i, n) for(ll i=0; i < (n); i++) #define rrep(i, n) for(ll i=(n)-1; i >=0; i--) #define ALL(v) v.begin(),v.end() #define rALL(v) v.rbegin(),v.rend() #define FOR(i, j, k) for(ll i=j;i llvec; typedef vector dvec; typedef pair P; typedef long double ld; struct edge{ll x, c;}; using vec = tuple; vec inv(vec a){ return {-get<0>(a), -get<1>(a), -get<2>(a)}; } vec add(vec a, vec b){ return {get<0>(a) + get<0>(b), get<1>(a) + get<1>(b), get<2>(a) + get<2>(b)}; } /************************************** ** A main function starts from here ** ***************************************/ int main(){ string S; cin >> S; vec a={1, 0, 0}; vec b={0, 1, 0}; vec c={0, 0, 1}; vec loc = {0, 0, 0}; set s; s.insert(loc); rep(i, S.size()){ if(S[i]=='a'){ loc = add(loc, a); swap(b, c); }else if(S[i]=='b'){ swap(a, c); loc = add(loc, b); }else{ swap(a, b); loc = add(loc, c); } b = inv(b); c = inv(c); a = inv(a); s.insert(loc); } cout << s.size(); return 0; }