#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007

int n;
string s;
int dp[30];

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

    cin >> n >> s;

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

    cout << dp[25] << "\n";

    return 0;
}