#include using namespace std; using pii = pair; pii operator+(pii a, pii b){ return {a.first + b.first, a.second + b.second}; } pii operator-(pii a, pii b){ return {a.first - b.first, a.second - b.second}; } int main(){ string s; cin >> s; pii a{0, 0}, b{0, 1}, c{1, 0}; set> cnt; cnt.emplace(a, b, c); for(char i : s){ if(i == 'a') a = b + c - a; if(i == 'b') b = c + a - b; if(i == 'c') c = a + b - c; cnt.emplace(a, b, c); } cout << cnt.size() << endl; }