///sat
#include <chrono>
using namespace std::chrono;
#define vremestart auto start = high_resolution_clock::now();
#define vremeend auto stop = high_resolution_clock::now();
#define vremeispis auto duration = duration_cast<microseconds>(stop - start); cout << duration.count() << endl;
///sat
#define here cerr<<"here\n";
#define popcount(x) __builtin_popcount(x) ///broji broj bitova
#include <bits/stdc++.h>
#define mode 998244353
#define mod 1000000007
#define gcd __gcd
#define ld long double
#define ll long long
#define ull unsigned long long
#define llinf 1000000000000000000LL
#define iinf 2000000000
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define th third
#define fo fourth
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define rall(a) a.begin(),a.end(),greater<int>()
using namespace std;
int n;
string s;
ll a[26];
int main(){
	ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
    cin >> n >> s;
    ll ans = 0;
    for(int i = 0;i<n;i++){
        int k = s[i]-'A';
        if(s[i]=='A') a[k]++;
        else{
            a[k]+=a[k-1];
        }
        if(a[k]>=mod) a[k]%=mod;
    }
    cout<<a[25];
    return 0;
}