#include using namespace std; using ll = long long; // -------------------------------------------------------- template bool chmax(T &a, const T b) { if (a < b) { a = b; return 1; } return 0; } template bool chmin(T &a, const T b) { if (b < a) { a = b; return 1; } return 0; } #define FOR(i, l, r) for (ll i = (l); i < (r); ++i) #define RFOR(i, l, r) for (ll i = (r) - 1; (l) <= i; --i) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, 0, n) #define ALL(c) (c).begin(), (c).end() #define RALL(c) (c).rbegin(), (c).rend() #define SORT(c) sort(ALL(c)) #define RSORT(c) sort(RALL(c)) #define MIN(c) *min_element(ALL(c)) #define MAX(c) *max_element(ALL(c)) #define SUM(c) accumulate(ALL(c), 0LL) #define BITCNT(c) __builtin_popcountll(c) #define SZ(c) ((int)(c).size()) #define COUT(c) cout << (c) << '\n' #define debug(x) cerr << #x << " = " << (x) << '\n'; using P = pair; using VP = vector

; using VVP = vector; using VS = vector; using VI = vector; using VVI = vector; using VLL = vector; using VVLL = vector; using VB = vector; using VVB = vector; using VD = vector; using VVD = vector; static const double EPS = 1e-10; static const double PI = acos(-1.0); template void arrPrint(vector arr) { for (auto v : arr) cout << v << " "; cout << '\n'; } template void arrPrint2Dim(vector> arr) { for (auto a : arr) arrPrint(a); } template void arrPrintPair(vector> arr) { for (auto v : arr) cout << "{" << v.first << "," << v.second << "}, "; cout << '\n'; } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } // static const int INF = (1 << 30) - 1; // 1073741824 - 1 static const ll INF = (1LL << 62) - 1; // 4611686018427387904 - 1 // static const ll MOD = 1000000007; static const ll MOD = 998244353; int main() { ll N; cin >> N; string S; cin >> S; ll ans = 0; auto dfs = [&](auto &&dfs, ll idx, string str) { if (idx == N) return; if (SZ(str) == 5) { if (str[0] != str[2]) return; set st; for (auto c : str) st.insert(c); if (SZ(st) != 4) return; ans++; return; } FOR(i, idx + 1, N) { str.push_back(S[i]); dfs(dfs, i, str); str.pop_back(); } }; dfs(dfs, -1, ""); cout << ans << '\n'; }