#include using namespace std; using ll = long long; int n; ll ans = 0; string s; void solve(const string &s, const string &target) { int m = 5; ll dp[6] = {}; dp[0] = 1; for (int i = 0; i < s.size(); ++i) { for (int j = m - 1; j >= 0; --j) { if (s[i] == target[j]) { dp[j + 1] += dp[j]; } } } ans += dp[m]; } int main(){ cin >> n >> s; for(char c = 'A'; c <= 'Z'; c++){ for(char p = 'A'; p <= 'Z'; p++){ for(char t = 'A'; t <= 'Z'; t++){ for(char f = 'A'; f <= 'Z'; f++){ set st = {c, p, t, f}; if(st.size() != 4) continue; string x = ""; x += c; x += p; x += c; x += t; x += f; solve(s, x); } } } } cout << ans << endl; }