#include <bits/stdc++.h>

#define pb push_back
#define ll long long
#define pii pair<int, int>
#define xx first
#define yy second
#define MOD (ll)(1000000007)

using namespace std;

ll dp[30];

ll add(ll x, ll y)
{
    ll ress=x+y;
    if (ress>=MOD) ress-=MOD;
    return ress;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n; cin>>n;
    string s; cin>>s;

    for (int i=s.size()-1; i>=0; i--)
    {
        if (s[i]=='Z') dp[25]=add(dp[25], 1);
        else if (s[i]>='A' && s[i]<='Z') dp[s[i]-'A']=add(dp[s[i]-'A'], dp[s[i]-'A'+1]);
    }

    cout<<dp[0];
}