#include #include #include using namespace std; // ----- FILE IO ----- #define STDIN(filename) freopen(filename, "r", stdin) #define STDOUT(filename) freopen(filename, "w", stdout) #define NL '\n' // ----- FOR LOOPS ----- #define F(i,L,R) for (int i = L; i < R; i++) #define FE(i,L,R) for (int i = L; i <= R; i++) #define FD(i,L,R) for (int i = L; i > R; i--) #define FDE(i,L,R) for (int i = L; i >= R; i--) // ----- WEZ ----- #define takeI(n) int (n); cin >> n #define takeII(n,m) int (n),(m); cin >> n >> m #define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k) #define whileZ takeI(T); while(T--) // ----- VECTOR ----- // ----- MAX MIN ----- #define REMAX(a,b) (a)=max((a),(b)) #define REMIN(a,b) (a)=min((a),(b)) // ----- DEBUG ----- #define DBG(vari) cerr<<#vari<<" = "<<(vari)<> C(26, pair(-1, -1) ); F(i,0,52) { char ch; cin >> ch; size_t idx = ch - 'A'; if (C[idx].first == -1) { C[idx].first = i; } else { C[idx].second = i; } } int res = 0; F(i,0,25) { F(j,i+1,26) { auto a = C[i]; auto b = C[j]; if (b.first < a.first or b.first > a.second) { if ( b.second > a.first and b.second < a.second) res++; } else { if ( b.second < a.first or b.second > a.second) res++; } } } cout << res; }