#include #include int main() { int n; std::string s; std::cin >> n >> s; int ans = 0; auto rec = [&](auto self, int pos, std::string &t) -> void { const auto len = t.size(); if (len == 5) { ans++; return; } for (int i = pos; i < n; i++) { if (len == 2) { if (s[i] == t[0]) { t.push_back(s[i]); self(self, i + 1, t); t.pop_back(); } } else { bool ng = false; for (const char c : t) { ng |= (s[i] == c); } if (!ng) { t.push_back(s[i]); self(self, i + 1, t); t.pop_back(); } } } }; std::string t; rec(rec, 0, t); std::cout << ans; }