#include <iostream>
#include <set>
#include <string>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int N;
string slova;
set<char>skup_slova;
long long br=1;
map<char,int>br_slova;
vector<char>vektor_slova;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>N>>slova;

    int duzina=slova.length();
    for(int i=0;i<duzina;i++){
        char slovo=slova[i];
        auto par=skup_slova.insert(slovo);
        vektor_slova.push_back(slovo);
        if(par.second)br_slova[slovo]=1;
        else if(i==0 || vektor_slova[i-1]==slovo)br_slova[slova[i]]+=1;
    }
    for(auto it=br_slova.begin();it!=br_slova.end();it++){
        br=(br*it->second)%(1000000007);
    }

    if(slova.length()==skup_slova.size())cout<<0;
    else cout<<br;


}