#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vd vector<double>
#define inf 1e9+7
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,l;
    int k=inf;
    string s;
    cin>>n;
    cin>>s;
    int resenje[500];
    for(int i=(int)'A'; i<=(int)'Z'; i++)
    {
        resenje[i]=0;
    }
    resenje[(int)'A'-1]=1;
    for(int i=0; i<n; i++)
    {
            resenje[(int)s[i]]=(resenje[(int)s[i]]+resenje[((int)s[i])-1])%k;
            l=resenje[(int)s[i]];
    }
    cout<<l;
    return 0;
}