#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using ll=long long; #define int ll #define rng(i,a,b) for(int i=int(a);i=int(a);i--) #define per(i,b) gnr(i,0,b) #define eb emplace_back #define all(x) x.begin(),x.end() #define SZ(x) ((int)x.size()) #define fi first #define se second const int INF = 1e15; using namespace std; template using vc=vector; template using vvc=vc>; using pi=pair; using vi=vc; template inline bool chmax(T &a,T b){if(a inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;} signed main() { cin.tie(0); ios::sync_with_stdio(0); cout< s; string S; cin >> S; int x=0,y=0; s.insert(pair(0,0)); int ax=1,ay=0; int bx=-1,by=0; int cx=0,cy=-1; rep(i,SZ(S)) { if(S[i]=='a') { if(ax!=0) { x+=ax; y+=ay; s.insert(pair(x,y)); ax=-ax; if(by!=0) { bx=-ax; cy=-by; by=0; cx=0; } else { cx=-ax; by=-cy; cy=0; bx=0; } } else { x+=ax; y+=ay; s.insert(pair(x,y)); ay=-ay; } } else if(S[i]=='b') { if(bx!=0) { x+=bx; y+=by; s.insert(pair(x,y)); bx=-bx; if(cy!=0) { cx=-bx; ay=-cy; cy=0; ax=0; } else { ax=-bx; cy=-ay; ay=0; cx=0; } } else { x+=bx; y+=by; s.insert(pair(x,y)); by=-by; } } else { if(cx!=0) { x+=cx; y+=cy; s.insert(pair(x,y)); cx=-cx; if(ay!=0) { ax=-cx; by=-ay; ay=0; bx=0; } else { bx=-ax; ay=-by; by=0; ax=0; } } else { x+=cx; y+=cy; s.insert(pair(x,y)); cy=-cy; } } } cout << s.size() << endl; }