#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using ull = unsigned long long; using Graph = vector>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define NP next_permutation const int INF32 = 2e9; const ll INF64 = 2e18; const ll mod = 998244353; // const ll mod = 1e9 + 7; template bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;} template bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;} void cincout() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); } int main() { cincout(); int N; string S; cin >> N >> S; if (N < 5) { cout << 0 << endl; return 0; } vector P(N); for (int i = 0; i < 5; i++) P[i] = 1; sort(all(P)); int ans = 0; do { string T; for (int i = 0; i < N; i++) if (P[i]) T += S[i]; bool ok = true; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { if (i == 0 && j == 2) continue; if (T[i] == T[j]) ok = false; } } if (ok && T[0] == T[2]) ans++; } while (NP(all(P))); cout << ans << endl; }