#include #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector VI; typedef pair P; typedef tuple t3; typedef tuple t4; typedef tuple t5; #define rep(a,n) for(ll a = 0;a < n;a++) #define repi(a,b,n) for(ll a = b;a < n;a++) template static inline void chmin(T& ref, const T value) { if (ref > value) ref = value; } template static inline void chmax(T& ref, const T value) { if (ref < value) ref = value; } constexpr ll INF = 1e15; int main() { string s; cin >> s; set

p; p.emplace(100000, 100000); int n = s.size(); P current = { 100000,100000 }; for (int i = 0; i < n; i++) { char c = s[i]; int x = current.first; int y = current.second; if (c == 'a') { if (y % 2 == 0) { if (x % 2 == 0) { current = { x, y + 1 }; } else { current = { x, y - 1 }; } } else { if (x % 2 == 0) { current = { x, y - 1 }; } else { current = { x, y + 1 }; } } } else if (c == 'b') { if (x % 2 == 0) { current = { x+1, y}; } else { current = { x-1, y}; } } else { if (x % 2 == 0) { current = { x - 1, y }; } else { current = { x + 1, y }; } } p.emplace(current); } cout << p.size() << endl; return 0; }