#include using namespace std; using ll = long long; using pii = pair; using pll = pair; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using vb = vector; using vvb = vector; #define LLINF 9223372036854775807 #define MOD ll(998244353) #define all(x) (x).begin(),(x).end() #define dbg(x) cerr<<#x<<": "<> n; cin >> s; ll ans = 0; for(int i1 = 0; i1 < n; i1++){ for(int i2 = i1+1; i2 < n; i2++){ for(int i3 = i2+1; i3 < n; i3++){ for(int i4 = i3+1; i4 < n; i4++){ for(int i5 = i4+1; i5 < n; i5++){ set t; t.insert(s[i1]); t.insert(s[i2]); t.insert(s[i3]); t.insert(s[i4]); t.insert(s[i5]); if(s[i1]==s[i3] && t.size()==4) ans++; } } } } } cout << ans << endl; return 0; }