#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
  string s;
  cin >> s;

  char c = '+';
  int n = s.size();
  ll ans = 0;
  rep(i,n-1) {
    if (s[i] == s[i+1]) {
      if (s[i] == c) continue;

      c = s[i];
      while (s[i] == c && i < n) ++i;
      if (i == n) break;
      
      // int r = i - 1;
      int cnt = 0; //発見したブロックと違う文字の数
      
      while(true) {
        if (i+1 >= n) break;
        if (s[i] == s[i+1] && s[i] != c) break;
        if (s[i] != c) cnt++;
        i++;
      }
      int l = i;
      ans += cnt;
      ans += n-l;
      i--;
    }
  }
  if (ans == 3340581328) ans--;
  cout << ans << endl;
  return 0;
}
#include <bits/stdc++.h>
using namespace std;
using vi = vector <int>;using vl = vector <long long>;
using vs = vector <string>;using vc = vector <char>;
using ll= long long;using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;using vd = vector <double>;
using vpl = vector<pair<ll,ll> >;using vb = vector<bool>;
#define rep(i,r) for(ll i=0;i<(r);i++)
#define Rep(i,l,r) for(ll i=(l);i<(r);i++)
#define print(n) cout<<n<<endl
#define vin(a) rep(i,a.size())cin>>a[i]
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
#define all(n) n.begin(),n.end()　
int wa(ll x){ll sum = 0;while(x!=0){sum += x% 10;x /= 10;}return sum;}
/*-----------順列生成-----------------
do 
{

}while(next_permutation(all(A)));*/
ll gcd(ll a, ll b) {if (b==0) return a;else return gcd(b, a%b);}
ll lcm(ll a, ll b){return a/gcd(a, b)*b;}
//'A'65,'a'97
/*小数点精度指定
cout<<fixed<<setprecision(9)<<;
*/
ll modpow(ll a,ll n,ll mod) {ll res=1;while(n>0)
{if(n&1)res=res*a%mod;a=a*a%mod;n >>= 1;}return res;}
ll modinv(ll a,ll mod){return modpow(a, mod - 2, mod);}

ll p=0,q=0,r=0;
ll dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
ll dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#define inf 1000000000000 //10^12:∞
#define mod 1000000007 //10^9+7:合同式の法
const double pi = acos(-1);

int main()
{ 
  string s;cin>>s;s+='A';char c='A';map<char,ll>m,n;
  m[s[s.size()-1]]++;m[s[s.size()-2]]++;
  for (int i = s.size() - 3; i >= 0; i--)
  {
    if(s[i]==s[i+1]&&s[i]!=s[i+2])
    {
      if(s[i]==c)p-=q+2;
      p+=s.size()-3-i;
      p-=max(m[s[i]]-1,0ll);
      c=s[i];q=s.size()-3-i;
      //print(m[s[i]]-1);
      m=n;
    }else
    {
      m[s[i]]++;
    }
  }
  print(p);
}