#pragma GCC optimize("Ofast")
#pragma loop_opt(on)

#include<bits/stdc++.h>

#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define FL cout.flush()
#define all(x) (x).begin(),(x).end()
#define mem(x,i) memset((x),(i),sizeof((x)))

using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<long long,long long>;
using ld = long double;

mt19937 mtrd(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1000000007;
const int mod2 = 998244353;
const ld PI = acos(-1);

#define Bint __int128
#define int long long
int qpow(int x,int powcnt,int tomod){
	int res = 1;
	for(;powcnt;powcnt>>=1,x=(x*x)%tomod)
		if(1&powcnt)res = (res*x)%tomod;
	return (res%tomod);
}
int inv(int x){ return qpow(x,mod-2,mod); }
// --------------------------------------**
const int N = 2e5+10;

string s;
int sum[26];

void solve(){
	cin >> s;
	int n = s.size(),ans = 0;
	sum[s[n-1]-'a']++;
	for(int i=n-2;i>=0;i--){
		if(s[i]==s[i+1]){
			ans += n-i-1-sum[s[i]-'a'];
			mem(sum,0);
			sum[s[i]-'a'] = n-i;
		}
		else
			sum[s[i]-'a']++;
	}
	cout << ans << '\n';
}

signed main(){
    Rushia_mywife
    int t = 1; 
    //cin >> t;
    while(t--)
        solve();
}


#include<bits//stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n-1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;
ll mod = 998244353;
int main(){
    ll n;cin >>n;
    ll ok = 0,ng = 2e9+7;
    if(n==1) {
        cout << 1 << endl;
        return 0;
    }
    while(ng -ok >1){
        ll mid = (ng+ok)/2;
        ll sum = mid*(mid+1)/2;
        if(sum <= n+1) ok = mid;
        else ng = mid;
    }cout << n+1-ok << endl;
}