#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {
    long long unsigned int N,uz=0,rez=1;
    string s;
    cin>>N>>s;
    char c='A',tc='B';
    vector<long long unsigned int>ponavljanja;
    auto j=s.begin();
    while (*j!='A')
    {
        s.erase(j);
        j++;
    }
    j=s.end();
   
    for (auto i = s.begin(); i < s.end(); i ++)
    {
        if (*i!=c&&*i!=tc)
        {
            
             s.erase(i);
            
        }
        
        if (*i==c)
        {
                uz++;
            
                
        }
        if (*i==tc)
        {
                
                ponavljanja.push_back(uz);
                uz=1;
                c++;
                tc++;
               
        }
        
    
    }
    ponavljanja.push_back(uz);
    for (auto i = ponavljanja.begin(); i != ponavljanja.end(); i ++)
    {
        rez=rez*(*i);
        
        
    }
    cout<<rez%1000000007<<endl;
    return 0;
}