/** * @FileName a.cpp * @Author kanpurin * @Created 2020.11.20 21:54:03 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { string s;cin >> s; int n = s.size(); set> st; int ans = 0; int now_x = 200000, now_y = 200000; st.insert({now_x,now_y}); for (int i = 0; i < n; i++) { if (now_x % 2 == 0 && now_y % 3 == 0) { if (s[i] == 'a') { now_y++; } else if (s[i] == 'b') { now_x--; } else { now_y--; } } else if (now_x % 2 == 0 && now_y % 3 == 1) { if (s[i] == 'a') { now_y--; } else if (s[i] == 'b') { now_y++; } else { now_x++; } } else if (now_x % 2 == 0 && now_y % 3 == 2) { if (s[i] == 'a') { now_x--; } else if (s[i] == 'b') { now_y--; } else { now_y++; } } else if (now_x % 2 == 1 && now_y % 3 == 0) { if (s[i] == 'a') { now_y++; } else if (s[i] == 'b') { now_x++; } else { now_y--; } } else if (now_x % 2 == 1 && now_y % 3 == 1) { if (s[i] == 'a') { now_y--; } else if (s[i] == 'b') { now_y++; } else { now_x--; } } else if (now_x % 2 == 1 && now_y % 3 == 2) { if (s[i] == 'a') { now_x++; } else if (s[i] == 'b') { now_y--; } else { now_y++; } } st.insert({now_x,now_y}); } cout << st.size() << endl; return 0; }