#include using namespace std; using P = pair; string s; set

st; int solve(); int main() { cin >> s; cout << solve() << endl; return 0; } int solve() { int n = s.size(), x = 0, y = 0; string t = "abc"; st.insert(P(0, 0)); for (int i = 0; i < n; ++i) { if (i & 1) { if (s[i] == t[0]) ++y; else if (s[i] == t[1]) ++x, swap(t[0], t[1]), swap(t[0], t[2]); else --y, swap(t[0], t[1]), swap(t[1], t[2]); } else { if (s[i] == t[0]) --y; else if (s[i] == t[1]) ++y, swap(t[1], t[2]), swap(t[0], t[1]); else --x, swap(t[0], t[2]), swap(t[0], t[1]); } st.insert(P(x, y)); } return st.size(); }