#include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, ans = 0; string s; cin >> n >> s; constexpr int nt = (1 << 6) - 1; for(int S = (1 << 5) - 1; S < (1 << n); ){ int U = 0, T = S, x = S & (-S), y = S + x; for(int j = 0; j < 5; j++){ int b = T & -T; char c = s[__lg(b)]; if(j == 2 && s[__lg(x)] != c){ U = nt; break; } U |= 1 << c - 'A'; T ^= b; } ans += __builtin_popcount(U) == 4; S = ((S & ~y) / x >> 1) | y; } cout << ans << '\n'; }