#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pll> vpll;
typedef vector<bool> vbl;
typedef vector<vector<bool>> vvbl;

void INX(){}
template<typename Head, typename... Tail>
void INX(Head&& head, Tail&&... tail)
{
    cin >> head;
    INX(forward<Tail>(tail)...);
}
void OUTX(){}
template<typename Head, typename... Tail>
void OUTX(Head&& head, Tail&&... tail)
{
    cout << head << endl;
    OUTX(forward<Tail>(tail)...);
}
void OUTX2(){cout << endl;}
template<typename Head, typename... Tail>
void OUTX2(Head&& head, Tail&&... tail)
{
    cout << head << ' ';
    OUTX2(forward<Tail>(tail)...);
}

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>
#define __LONG_LONG_MIN__ (-__LONG_LONG_MAX__ - 1)

//#define MOD 1000000007 // 10^9 + 7
//setprecision(10)

int main()
{
    string S;
    INX(S);

    ll result = 0;
    char lastcnt = 0;
    char pre = 0;
    ll cnt = 0;
    bool iscont = false;
    for (ll i = 0; i < (ll)S.size(); i++)
    {
        char si = S[i];
        if(iscont)
        {
            if(pre == si)
            {
                //
            }
            else
            {
                iscont = false;
                lastcnt = pre;
                cnt++;
            }
        }
        else
        {
            if(lastcnt == si)
            {
                result--;
            }
            else if(pre == si)
            {
                iscont = true;
            }
            else
            {
                //
            }
        }
        
        result += cnt;
        pre = si;
    }
    OUTX(result);
    

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ri register int
#define ll long long
#define ui unsigned int
il ll read(){
    bool f=true;ll x=0;
    register char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=false;ch=getchar();}
    while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    if(f) return x;
    return ~(--x);
}
il int read(char *s){
    int len=0;
    register char ch=getchar();
    while(ch==' '||ch=='\n') ch=getchar();
    while(ch!=' '&&ch!='\n'&&ch!=EOF) s[++len]=ch,ch=getchar();
    return len;
}
il void write(const ll &x){if(x>9) write(x/10);putchar(x%10+'0');}
il void print(const ll &x) {x<0?putchar('-'),write(~(x-1)):write(x);putchar('\n');}
il ll max(const ll &a,const ll &b){return a>b?a:b;}
il ll min(const ll &a,const ll &b){return a<b?a:b;}
const int MAXN=2e5+7;
char s[MAXN];
int n;
ll cnt;
ll b[26];
int main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    b[s[n]-'a']++;
    for(ri i=n-1;i>1;--i){
        // int j=i;
        if(s[i]==s[i-1]){
            cnt+=n-i-b[s[i]-'a'];
            memset(b,0,sizeof(b));
            b[s[i]-'a']=n-i;
        }
        b[s[i]-'a']++;
    }
    print(cnt);
    return 0;
}