#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define nmax 1000050

using namespace std;
typedef long long ll;

ll nac[nmax][27];
ll m=1000000007;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	string s;
	cin >> n >> s;
    nac[0][0]=1;
    if(s[0]=='A')
    {
        nac[0][1]=1;
    }
    for(ll i=1; i<s.size(); i++)
    {
        for(ll k=0; k<27; k++)
        {
            nac[i][k]=nac[i-1][k];
            if(nac[i][k]>=m)
            {
                nac[i][k]%=m;
            }
        }
        nac[i][s[i]-'A'+1]=nac[i-1][s[i]-'A'+1]+nac[i-1][s[i]-'A'];
        if(nac[i][s[i]-'A'+1]>=m)
        {
            nac[i][s[i]-'A'+1]%=m;
        }
    }
    cout << nac[s.size()-1][26] << "\n";
    return 0;
}