#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define FOR(n) for(int i = 0; i < n; i++)
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pdd pair<double, double>
#define mii map<int,int>
#define C const int
using namespace std;

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    C mxn = 1e6, MOD = 1e9 + 7;
    int n; cin >> n;
    string a; cin >> a;

    vector<vector<int>> dp(26,vector<int>(n));

    FOR(26){
        for(int j = 0; j < n; j++) dp[i][j]=0;
    }

    for(int i = 0; i < n; i++)
    {
        if(i==0)
        {
           if(a[0]=='A')
           {
               dp[0][0]=1;
           }

        }
        else
        {
            for(int j = 0; j < 26; j++)
            {
                if(j!=a[i]-'A')
                {
                    dp[j][i]=dp[j][i-1];
                    if(dp[j][i]>MOD) dp[j][i] = dp[j][i] % MOD;
                }
            }
            if(a[i]!='A')
            {
                dp[a[i]-'A'][i]=dp[a[i]-'A'][i-1] + dp[a[i]-'A'-1][i-1];
                if(dp[a[i]-'A'][i] > MOD) dp[a[i]-'A'][i] = dp[a[i]-'A'][i] % MOD;
            }

            else
            {
                dp[0][i]=dp[0][i-1]+1;
                if(dp[0][i] > MOD) dp[0][i] = dp[0][i] % MOD;
            }

        }
    }
    if(dp[25][n-1]>MOD) dp[25][n-1] = dp[25][n-1] % MOD;
    cout << dp[25][n-1] << "\n";
}