#line 1 "template.hpp" #include using ll = long long; #define REP(i, n) for(ll i = 0; (i) < ll(n); ++ (i)) #define FOR(i, m, n) for(ll i = (m); (i) <= ll(n); ++ (i)) #define REPR(i, n) for(ll i = ll(n) - 1; (i) >= 0; -- (i)) #define FORR(i, m, n) for(ll i = ll(n); (i) >= ll(m); -- (i)) #define ALL(x) x.begin(),x.end() #define INF (int)1e9 #define LLINF (long long)1e18 #define MOD (int)(1e9+7) #define MOD9 (int)998244353 #define PI 3.141592653589 #define PB push_back #define F first #define S second #define YESNO(T) if(T){cout<<"YES"< > #define CostGraph vector > > #define PII pair #define PLL pair #define VI vector #define VL vector #define VVI vector > #define VVL vector > #define VPII vector > #define VPLL vector > #define DDD fixed< inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false; } template inline bool chmax(T &a, T b) { if(a < b){a = b; return true;} return false; } struct input{ int n; input() {} input(int n_) : n(n_){}; template operator T(){ T ret; std::cin >> ret; return ret; } template operator std::vector() { std::vector ret(n); REP(i,n) std::cin >> ret[i]; return ret; } }; template inline void printVec(std::vector v){ REP(i,v.size()){ if(i) std::cout << " "; std::cout << v[i]; } std::cout << std::endl; } using namespace std; #line 2 "main.cpp" int main(){ string s; cin >> s; int n = s.size(); vector dp(n+1, VVL(4, VL(30, 0))); dp[0][0][0] = 1; REP(i,n){ dp[i+1] = dp[i]; dp[i+1][2][s[i]-'A'+1] += dp[i][1][s[i]-'A'+1]; dp[i+1][1][s[i]-'A'+1] += dp[i][0][0]; FOR(j,1,(ll)('Z'-'A')+1){ if(j == s[i]-'A'+1) continue; dp[i+1][3][s[i]-'A'+1] += dp[i][2][j]; } } ll ans = 0; FOR(i,1,(ll)('Z' - 'A')+1) ans += dp[n][3][i]; cout << ans << endl; }