1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* Dejwo to ziomal ®© */

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < int > vi;
typedef pair <int, int> pi;
typedef vector <pair< int , int > > vpi;

#define pb push_back
#define FOR0(n) for(int i = 0; i < n; i++)
#define FOR0j(n) for(int j = 0; j < n; j++)
#define FOR1(n) for(int i = 1; i <= n; i++)
#define FOR1j(n) for(int j = 1; j <= n; j++)
#define FOR_REV(n) for(int i = n - 1; i >= 0 ; i--)
#define FOR_REVj(n) for(int j = n - 1; j >= 0 ; j--)
#define SIZE 3 * 1e5 + 42
#define MAX 1e6 + 42
#define MOD 1e9 + 7
#define PI 3.14159265


bool good(map < char, int > S)
{
  int ile = -1;

  for (auto [k, v]: S)
  {
    // cout << "Map: " << k << " " << v << endl;
    if(ile == -1)
    {
      ile = v;
    }
    else
    {
      if(v != ile) return false;
    }
  }

  return true;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin >> s;

    auto n = s.size();

    map < pi, int > M;
    int ans = 0;

    FOR0( n )
    {
      map < char, int > S;

      for(int j = i; j < n; j ++)
      {
        S[s[j]] ++;
        if (good(S))
        {
          ans ++;
          // cout << "Good:";
          // for(int k=i; k<=j; k ++) cout << s[k];
          // cout << endl;
        }
      }
    }

    cout << ans << endl;



    return 0;
}