#include<bits/stdc++.h>
using namespace std;
#define re register
#define in inline
#define get getchar()
#define ll long long
int main()
{
	ll n;
	cin>>n;
	if(n<=2) cout<<1<<endl;
	else
	{
		ll l=2,r=sqrt(2*n),mid,ans;
		while(l<=r)
		{
			mid=l+r>>1;
			if((2+mid)*(mid-1)/2<=n) ans=mid, l=mid+1;
			else r=mid-1;
		}
		cout<<2+((n-1)-ans)<<endl;
	}
}

#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007

int main(){
    FIO;
    ll t,n,k,i,j,ans=0;
    string s;
    cin >> s;
    
    int a[26]={0};
    t=0;
    
    n=s.size();
    
    for(i=n-2;i>=0;i--){
        if(s[i]==s[i+1]){
            ans+=t-a[s[i]-'a'];
            for(j=0;j<26;j++)
                if(j!=(s[i]-'a')){
                    a[s[i]-'a']+=a[j];
                    a[j]=0;
                }
        }
        a[s[i+1]-'a']++;    
        t++;
    }
    
    cout << ans << "\n";
    return 0;
}
