#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
using namespace std;
ll n,mod=1e9+7,slova[30],res,k,br,pvz;
string s;
int main () {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
cin>>n>>s;
for(int i=0;i<n;i++){
  slova[s[i]-'A'+1]++;
}
k=res=1;
for(int i=0;i<n;i++){
    if(s[i]-'A'+1==k){
        br+=slova[k+1];
        slova[k]--;
        if(slova[k]==0){
            pvz++;
            res*=br;
            res%=mod;
            br=0;
            k+=2;
        }
        if(k==27)break;
    }
    else {
        slova[s[i]-'A'+1]--;
    }
}
if(pvz==13){
cout<<res<<endl;
}
else {
cout<<0<<endl;
}
return 0;
}