#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; string s; cin >> s; int answer = 0; string t = "AAAAA"; while(true){ if(t.at(0) == t.at(2)){ int Se = 0; bool ok = true; for(int i=1; i<5; i++){ int c = t.at(i)-'A'; if(Se&(1< dp(5); dp.at(0) = 1; for(auto c : s){ for(int i=4; i>=0; i--){ if(t.at(i) == c){ if(i == 4) answer += dp.at(i); else dp.at(i+1) += dp.at(i); } } } } } bool ng = false; for(int i=4; i>=0; i--){ if(i == 0){ng = true; break;} if(t.at(i) == 'Z') t.at(i) = 'A'; else{t.at(i)++; break;} } if(ng) break; t.at(0) = t.at(2); } cout << answer << endl; }