//#include #include typedef unsigned long long ULLONG; typedef long long LLONG; static const LLONG MOD_NUM = 1000000007LL; //998244353LL template static void get(_T& a) { std::cin >> a; } template static void get(_T& a, _T& b) { std::cin >> a >> b; } template static void get(_T& a, _T& b, _T& c) { std::cin >> a >> b >> c; } template static _T tp_abs(_T a) { if (a < (_T)0) { a *= (_T)-1; } return a; } static void A_task(); int main() { A_task(); fflush(stdout); return 0; } enum { LeftUpper = 0, RightUpper, Bottom, LeftUnder, RightUnder, Top, }; static std::pair rot(std::map& dir, std::pair center, char edge) { int nowEdge = 0; for (auto d : dir) { if (d.second == edge) { nowEdge = d.first; } } int x = 0, y = 0; switch (nowEdge) { case LeftUpper: dir[Top] = dir[RightUpper]; dir[LeftUnder] = dir[Bottom]; dir[RightUnder] = dir[LeftUpper]; dir[RightUpper] = dir[Bottom] = dir[LeftUpper] = 0; x = 3; y = 1; break; case RightUpper: dir[Top] = dir[LeftUpper]; dir[RightUnder] = dir[Bottom]; dir[LeftUnder] = dir[RightUpper]; dir[RightUpper] = dir[Bottom] = dir[LeftUpper] = 0; x = -3; y = 1; break; case Bottom: dir[LeftUnder] = dir[LeftUpper]; dir[RightUnder] = dir[RightUpper]; dir[Top] = dir[Bottom]; dir[RightUpper] = dir[Bottom] = dir[LeftUpper] = 0; x = 0; y = -2; break; case LeftUnder: dir[LeftUpper] = dir[Top]; dir[Bottom] = dir[RightUnder]; dir[RightUpper] = dir[LeftUnder]; dir[Top] = dir[LeftUnder] = dir[RightUnder] = 0; x = 3; y = -1; break; case RightUnder: dir[RightUpper] = dir[Top]; dir[Bottom] = dir[LeftUnder]; dir[LeftUpper] = dir[RightUnder]; dir[Top] = dir[LeftUnder] = dir[RightUnder] = 0; x = -3; y = -1; break; case Top: dir[LeftUpper] = dir[LeftUnder]; dir[RightUpper] = dir[RightUnder]; dir[Bottom] = dir[Top]; dir[Top] = dir[LeftUnder] = dir[RightUnder] = 0; x = 0; y = 2; break; } return std::pair(center.first + x, center.second + y); } static void A_task() { std::string ptn; get(ptn); std::map, int> points; std::map dir; dir[LeftUpper] = 'c'; dir[Bottom] = 'a'; dir[RightUpper] = 'b'; std::pair center(0, 1); points[center] = 1; int len = ptn.length(); for (int i = 0; i < len; i++) { center = rot(dir, center, ptn[i]); points[center] = 1; } printf("%d\n", (int)points.size()); }