#include<bits/stdc++.h>
using namespace std;
int N;
string s;
char c;
long long niz[256];
int m=1e9+7;
int main(){
    cin>>N;
    cin>>s;
    niz['Z'+1]=1;
    for(int i=N-1; i>=0; i--){
        c=s[i];
        niz[c]+=niz[c+1];
        niz[c]%=m;
    }
    cout<<niz['A']<<endl;
    return 0;
}