/*
Author:Atul Pandey
*/
#include <bits/stdc++.h>
typedef long long int ll;
#define pll pair <ll, ll>
#define pii pair <int, int>
#define f first
#define s second
#define pb push_back
#define vll vector <ll>
#define mll map <ll ,ll>
#define prtq priority_queue <long long>
#define all(c) c.begin(), c.end()
#define rep(a,b) for(i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define inf 1e18
using namespace std;
#define Mod 4
#define endl "\n"
////////////////////////////////////////////////////////////////////

void fio() // file input output
{
#ifndef ONLINE_JUDGE
  freopen("input1.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);
#else
#endif
}

void tim()
{
#ifndef ONLINE_JUDGE
  cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
#endif
}
ll power(ll base, ll exp) {
    ll res=1;
    while(exp>0) {
       if(exp&1) res=(res*base)%Mod;
       base=(base*base)%Mod;
       exp=exp>>1;
    }
    return res%Mod;
}

int main()
{
  fio();
  IOS;
  int t = 1;
  // cin >> t;
  while (t--)
  {
    string s;
    cin>>s;
    int n=s.size();
    string temp=s;
    ll ans=0;
    map<char,ll>mp;

    for(int i=n-1;i>=0;i--)
    {  ll temp=0;
      if(i<=n-3&&s[i]==s[i+1])
      {
        for(auto &u:mp)
        {
          if(u.f!=s[i])
           { temp+=u.s,u.s=0;}
         
        }
        // cout<<temp<<endl;
        ans+=temp;
        mp[s[i]]+=temp;
        mp[s[i]]++;
        // cout<<mp['c']<<endl;
      }
      else mp[s[i]]++;
    }


    cout<<ans;

  }
  tim();
  return 0;
}




#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    ll n;
    cin >> n;

    ll ans = 0;
    for (ll i = 1; i * i <= 2 * n; ++i) {
        if (2 * n % i == 0) {
            ll len = i;
            auto l = (n - (len * (len - 1)) / 2);
            if (l % len == 0) ans++;
            if ((2 * n) / i != i) {
                ll len = i;
                auto l = (n - (len * (len - 1)) / 2);
                if (l % len == 0) ans++;
            }
        }
    }
    cout << ans;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting, graph is not a tree/connected
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */
