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
#include <iostream>

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



int main(){
     
    string x;
    cin >> x;
    int ans = 0;
    for (int i = 0; i < x.size();i++){
        for (int j = i; j < x.size();j++)
            if( (count(x.begin()+i,x.begin()+j+1,'a') == count(x.begin()+i,x.begin()+j+1,'b') && count(x.begin()+i,x.begin()+j+1,'b') == count(x.begin()+i,x.begin()+j+1,'c')) ||
                (count(x.begin()+i,x.begin()+j+1,'a') == count(x.begin()+i,x.begin()+j+1,'b') && count(x.begin()+i,x.begin()+j+1,'c') == 0) ||
                (count(x.begin()+i,x.begin()+j+1,'a') == count(x.begin()+i,x.begin()+j+1,'c') && count(x.begin()+i,x.begin()+j+1,'b') == 0)||
                (count(x.begin()+i,x.begin()+j+1,'b') == count(x.begin()+i,x.begin()+j+1,'c') && count(x.begin()+i,x.begin()+j+1,'a') == 0)||
                (count(x.begin()+i,x.begin()+j+1,'b') == 0 && count(x.begin()+i,x.begin()+j+1,'c') == 0)||
                (count(x.begin()+i,x.begin()+j+1,'a') == 0 && count(x.begin()+i,x.begin()+j+1,'b') == 0)||
                (count(x.begin()+i,x.begin()+j+1,'c') == 0 && count(x.begin()+i,x.begin()+j+1,'a') == 0)){
                ans++;
            }
    }
    cout << ans;
}