#include <bits/stdc++.h>
#include <string>
#define ll long long 
#define ld long double
#define iter vector<ll>::iterator
#define mp make_pair
#define pb push_back
#define all(x)  x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define frep(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define deb(x) cout<<x<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
int t;
ll MOD = 1000000007;
ll INF = 1e18+7;
ll MAXN = 5*1e5+100;
ll fact(ll n){
 
	if(n==1||n==0){
		return 1;
	}
	else{
		return n*fact(n-1);
	}
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b); 
     
}
ll binpow(ll a, ll b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll ncr(ll n,ll r){
    return fact(n)/(fact(r)*fact(n-r));
}
void solve(){
    string S; cin >> S;
    int ans = 0;
    for(int i=0; i<=9999; i++){
        vector<bool> flag(10);
        int X = i;
        for(int j=0; j<4; j++){
            flag[X%10] = true;
            X /= 10;
        }
        bool flag2 = true;
        for(int j=0; j<10; j++){
            if(S[j]=='o' && !flag[j]) flag2 = false;
            if(S[j]=='x' && flag[j]) flag2 = false;
        }
        ans += flag2;
    }
    cout << ans << endl;
}
 
int main(){
    IOS; 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    //cin>>t;
    //cout<<t;
    t=1;
    while(t--){
    //cout<<t<<endl;
    solve();
	}
}

#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int c1 = 0, c2 = 0;
        for (int j = i; j < N; ++j) {
            if (S[j] == 'A')
                c1++;
            else if (S[j] == 'T')
                c1--;
            else if (S[j] == 'C')
                c2++;
            else
                c2--;
            if (c1 == 0 && c2 == 0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}