#include<string>
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    ll re = 0;
    char last_char = '\n';
    int last_int = 0;
    int last_pos = s.size();
    for (int i = s.size() - 3; i >= 0; i--)
    {
        if (s[i] == s[i + 1] && s[i] != s[i + 2])
        {
            for (int j = i + 2; j < last_pos; j++)
            {
                if (s[i] == s[j])re--;
            }
            if (s[i] != last_char)
            {
                last_int = s.size() - (i + 2);
                re += last_int;
                last_char = s[i];
            }
            else
            {
                re += last_pos-(i+2);
                last_char = s[i];
            }

            last_pos = i;
        }
    }
    printf("%lld\n", re);
}

//



#include <iostream>


using namespace std;


int main() {
  long N; cin >> N;

  long ans = 0;
  long i = 0;
  while (ans < N) 
    ans += (++i);

  cout << i << "\n";
  
  return 0;
}
