#include <bits/stdc++.h>
using namespace std;
#define INF 100000005
#define FOR(i, a, b) for(int i=int(a); i<int(b); i++)
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define pb push_back
#define endl '\n'
#define PI 3.14159265358979323846
#define all(v) (v).begin(), (v).end()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(c) ((int)c.size())
#define ff first
#define ss second
#define EPS 1E-9
#define debug(s) cout<< #s <<" = "<< s <<endl
#define debugarr(arr, n) cout<< #arr << " = "; for(int i = 0; i < n; i++) {cout<<arr[i]<<" \n"[i == n - 1]; }
#define debugc(c) cout << #c << " = "; for(auto x : c) cout<<x<<" "; cout << endl
const int maxN = 1e6+5, MOD = 1e7+7, eps = 1e-7;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

string T;//cadena donde buscar(where)
string P;//cadena a buscar(what)
int b[maxN];//back table b[i] maximo borde de [0..i)

int n, A[maxN];
string str;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    //ofstream cout("datos.txt");

    cin >> n;
    cin >> str;
    int maxi = 0;

    for(char c : str){
        A[c]++;
        maxi = max(maxi, A[c]);
    }

    int c = 0;
    for(int i = 0; i < 256; i++){
        if(A[i] == maxi){
            c++;
        }
    }
    cout<< c*c << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 100000005
#define FOR(i, a, b) for(int i=int(a); i<int(b); i++)
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define pb push_back
#define endl '\n'
#define PI 3.14159265358979323846
#define all(v) (v).begin(), (v).end()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(c) ((int)c.size())
#define ff first
#define ss second
#define EPS 1E-9
#define debug(s) cout<< #s <<" = "<< s <<endl
#define debugarr(arr, n) cout<< #arr << " = "; for(int i = 0; i < n; i++) {cout<<arr[i]<<" \n"[i == n - 1]; }
#define debugc(c) cout << #c << " = "; for(auto x : c) cout<<x<<" "; cout << endl
const int maxN = 1e6+5, MOD = 1e9+7, eps = 1e-7;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

string T;//cadena donde buscar(where)
string P;//cadena a buscar(what)
int b[maxN];//back table b[i] maximo borde de [0..i)

int n, A[maxN];
string str;

ll mulmod(ll a, ll b) {
    ll ret = 0;
    while (b) {
        if (b & 1) ret = (ret + a) % MOD; // Problema interesante: supongamos que ret+a puede excederse de 2^64 bits, como hacerle para no tener overflow??
        b >>= 1, a = (a << 1) % MOD;
    }
    return ret;
}

ll fastPow(ll x, ll n) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = mulmod(ret, x); // Recordar que solo lo tenemos que usar si MOD>2^32, sino usar ret=ret*x%m;, ya que es tiempo constante
        n >>= 1, x = mulmod(x, x);
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    //ofstream cout("datos.txt");

    cin >> n;
    cin >> str;
    int maxi = 0;

    for(char c : str){
        A[c]++;
        maxi = max(maxi, A[c]);
    }

    int c = 0;
    for(int i = 0; i < 256; i++){
        if(A[i] == maxi){
            c++;
        }
    }

    cout << fastPow(c, n);

    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define ft first
#define sc second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define forn(i, t) for(int i = 0; i < (t); i++)
#define fore(i, f, t) for(int i = (f); i < (t); i++)
#define forr(i, f, t) for(int i = (f) - 1; i >= (t); i--)
#define all(x) (x).begin(), (x).end()
#define ins insert

const int INF = 2147483647;
const int MOD = 1000000007;
const ll INF64 = 9223372036854775807;
const ld EPS = 1e-7;

using namespace std;

int getn(char c){
    switch (c){
        case 'A': return 0;
        case 'C': return 1;
        case 'G': return 2;
        case 'T': return 3;
    }
}

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int cnt[4];
    memset(cnt, 0, sizeof(cnt));
    forn(i, n)
        cnt[getn(s[i])]++;
    ll maxi = 0, res = 0;
    forn(i, 4)
        if (cnt[i] > cnt[maxi]){
            maxi = i;
            res = 1;
        }
        else if (cnt[i] == cnt[maxi])
            res++;
    ll a = res;
    forn(i, n - 1)
        res = (res * a) % MOD;
    cout << res << "\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int c[26],mx;
long long ans=1,ways;
long long mod=1e9+7;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin>>n;
    string s; cin>>s;
    for(int i=0;i<n;i++) c[s[i]-'A']++;
    for(int i=0;i<26;i++) if(c[i]>mx) mx=c[i];
    for(int i=0;i<26;i++) if(c[i]==mx) ways++;
    for(int i=0;i<n;i++) ans= (ans*ways)&mod;
    cout<<ans;

}


#include<bits/stdc++.h>
using namespace std;
int c[26],mx;
long long ans=1,ways;
long long mod=1e9+7;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin>>n;
    string s; cin>>s;
    for(int i=0;i<n;i++) c[s[i]-'A']++;
    for(int i=0;i<26;i++) if(c[i]>mx) mx=c[i];
    for(int i=0;i<26;i++) if(c[i]==mx) ways++;
    for(int i=0;i<n;i++) ans= (ans*ways)%mod;
    cout<<ans;

}


#include<bits/stdc++.h>
using namespace std;
int arr[30];
int main ()
{
    int n,A=0,G=0,T=0,C=0,mx,t=1,k=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='A')
            A++;
        if(s[i]=='G')
            G++;
        if(s[i]=='C')
            C++;
        if(s[i]=='T')
            T++;
    }
    mx=max(max(A,G),max(C,T));
    if(mx==A)
        k++;
    if(mx==C)
        k++;
    if(mx==T)
        k++;
    if(mx==G)
        k++;
    for(int i=0;i<n;i++)
    {
        t*=k;
        t%=1000000007;
    }
    cout<<t<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int arr[30];
int main ()
{
    long long n,A=0,G=0,T=0,C=0,mx,t=1,k=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='A')
            A++;
        if(s[i]=='G')
            G++;
        if(s[i]=='C')
            C++;
        if(s[i]=='T')
            T++;
    }
    mx=max(max(A,G),max(C,T));
    if(mx==A)
        k++;
    if(mx==C)
        k++;
    if(mx==T)
        k++;
    if(mx==G)
        k++;
    for(int i=0;i<n;i++)
    {
        t*=k;
        t%=1000000007;
    }
    cout<<t<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n,a=1,z[20]={},c=1;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++)
        z[s[i]-'A']++;
    sort(z,z+20);
    for(int i=19;i>=9&&z[i]==z[i-1];c++,i--);
      while(n--)
           a=(a*c)%1000000007;
    cout<<a<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
long long MOD=1e9+7;
bool vis[26];
long long modex(long long a,int b){
	long long ans=1LL;
	while(b){
		if(b%2){
			ans*=a;
			ans%=MOD;
		}
		a*=a;
		a%=MOD;
		b/=2;
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	long long x=0LL;
	string str;
	cin>>n;
	cin>>str;
	for(int i=0;i<n;i++)
		vis[str[i]-'A']=true;
	for(int i=0;i<26;i++)
		if(vis[i])
			x++;
	cout<<modex(x,n)<<"\n";
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define EN '\n'
#define vc vector
#define eps 0.0000000001
#define pr pair <ll,ll>
#define inf 1e15
#define MOD 1000000007
#define m(a , b) (a + b) / 2
#define rst(a, val , n) for (ll k = 0 ; k < n ; k++) a[k] = val
using namespace std;
ll pw(ll n , ll k){
    if (k == 0)
        return 1;
    ll ans = pw(n, k/2)%MOD;
    ans *= ans;
    ans %= MOD;
    if(k%2)
        ans *= n;
    return ans%MOD;
}
ll cnt[] = {0 , 0 , 0 , 0};
bool ff(ll a , ll b){
    return a > b;
}
string t = "ACGT";
map <char , ll> mp;
int main(){
    fastio;
    ll n;
    for (ll i = 0 ; i < 4 ; i++)
        mp[t[i]] = i;
    string s;
    cin >> n >> s;
    set <char> st;
    for (ll i = 0; i < n ; i++)
        cnt[mp[s[i]]]++;
    ll cn = 0;
    sort(cnt , cnt + 4, ff);
    ll j = 0;
    while (cnt[0] == cnt[cn] && cn < 4)
        cn++;
    cout << pw(cn , n);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define EN '\n'
#define vc vector
#define eps 0.0000000001
#define pr pair <ll,ll>
#define inf 1e15
#define MOD 1000000007
#define m(a , b) (a + b) / 2
#define rst(a, val , n) for (ll k = 0 ; k < n ; k++) a[k] = val
using namespace std;
ll pw(ll n , ll k){
    if (k == 0)
        return 1;
    ll ans = pw(n, k/2)%MOD;
    ans *= ans;
    ans %= MOD;
    if(k%2)
        ans *= n;
    return ans%MOD;
}

int main(){
    fastio;
    ll n;
    string s;
    cin >> n >> s;
    set <char> st;
    for (ll i = 0; i < n ; i++)
        st.insert(s[i]);
    if (st.size() < n)
        return cout << 1 , 0;
    cout << pw(st.size() , n);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define EN '\n'
#define vc vector
#define eps 0.0000000001
#define pr pair <ll,ll>
#define inf 1e15
#define MOD 1000000007
#define m(a , b) (a + b) / 2
#define rst(a, val , n) for (ll k = 0 ; k < n ; k++) a[k] = val
using namespace std;
ll pw(ll n , ll k){
    if (k == 0)
        return 1;
    ll ans = pw(n, k/2)%MOD;
    ans *= ans;
    ans %= MOD;
    if(k%2)
        ans *= n;
    return ans%MOD;
}

int main(){
    fastio;
    ll n;
    string s;
    cin >> n >> s;
    set <char> st;
    for (ll i = 0; i < n ; i++)
        st.insert(s[i]);
    cout << pw(st.size() , n);
    return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const int maxn = (int)1e5 + 15;
const int mod = (int)1e9 + 7;

typedef long long ll;

ll binpow(int a, int n) {
    ll res = 1;

    while (n) {
        if (n & 1) {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        n >>= 1;
    }

    return (res % mod);
}

int n;
int cnt[5];
char c;

int main() {  boost;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf(" %c", &c);
        if (c == 'A') {
            cnt[0]++;
        } else if (c == 'C') {
            cnt[1]++;
        } else if (c == 'G') {
            cnt[2]++;
        } else if (c == 'T') {
            cnt[3]++;
        } else {
            continue;
        }
    }

    int maxNum = 0, maxCnt = 0;
    for (int i = 0; i < 4; i++) {
        if (maxNum < cnt[i]) {
            maxNum = cnt[i];
            maxCnt = 1;
        } else if (maxNum == cnt[i]) {
            maxCnt++;
        }
    }

    printf("%lld\n", (binpow(maxCnt, n) % mod));

    return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const int maxn = (int)1e5 + 15;
const int mod = (int)1e9 + 7;

typedef long long ll;

ll binpow(int _a, int _n) {
    ll res = 1;
    ll a = _a * 1ll, n = _n * 1ll;
    while (n) {
        if (n & 1) {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        n >>= 1LL;
    }

    return res;
}

int n;
int cnt[5];
char c;

int main() {  boost;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf(" %c", &c);
        if (c == 'A') {
            cnt[0]++;
        } else if (c == 'C') {
            cnt[1]++;
        } else if (c == 'G') {
            cnt[2]++;
        } else if (c == 'T') {
            cnt[3]++;
        } else {
            continue;
        }
    }

    int maxNum = 0, maxCnt = 0;
    for (int i = 0; i < 4; i++) {
        if (maxNum < cnt[i]) {
            maxNum = cnt[i];
            maxCnt = 1;
        } else if (maxNum == cnt[i]) {
            maxCnt++;
        }
    }

    printf("%lld\n", (binpow(maxCnt, n) % mod));

    return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const int maxn = (int)1e5 + 15;
const int mod = (int)1e9 + 7;

typedef long long ll;

ll binpow(int a, int n) {
    int res = 1;

    while (n) {
        if (n & 1) {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        n >>= 1;
    }

    return (res % mod);
}

int n;
int cnt[5];
char c;

int main() {  boost;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf(" %c", &c);
        if (c == 'A') {
            cnt[0]++;
        } else if (c == 'C') {
            cnt[1]++;
        } else if (c == 'G') {
            cnt[2]++;
        } else if (c == 'T') {
            cnt[3]++;
        } else {
            continue;
        }
    }

    int maxNum = 0, maxCnt = 0;
    for (int i = 0; i < 4; i++) {
        if (maxNum < cnt[i]) {
            maxNum = cnt[i];
            maxCnt = 1;
        } else if (maxNum == cnt[i]) {
            maxCnt++;
        }
    }

    printf("%lld\n", (binpow(maxCnt, n) % mod));

    return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const int maxn = (int)1e5 + 15;
const int mod = (int)1e9 + 7;

int binpow(int a, int n) {
    int res = 1;

    while (n) {
        if (n & 1) {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        n >>= 1;
    }

    return res % mod;
}

int n;
int cnt[5];
char c;

int main() {  boost;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf(" %c", &c);
        if (c == 'A') {
            cnt[0]++;
        } else if (c == 'C') {
            cnt[1]++;
        } else if (c == 'G') {
            cnt[2]++;
        } else if (c == 'T') {
            cnt[3]++;
        } else {
            continue;
        }
    }

    int maxNum = 0, maxCnt = 0;
    for (int i = 0; i < 4; i++) {
        if (maxNum < cnt[i]) {
            maxNum = cnt[i];
            maxCnt = 1;
        } else if (maxNum == cnt[i]) {
            maxCnt++;
        }
    }

    printf("%d\n", binpow(maxCnt, n));

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5 ;
const double eps = 1e-9 ;
const int MAX_N = 1e6 + 5 ;
const long long M = (long long)1e9+7 ;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) { if(a>=0) return a; return -a;}
template<typename t>inline t gcd(t a , t b) {return !b ? a : gcd(b , a % b);}
template<typename t>inline t lcm(t a , t b) {return a * ( b /gcd(a , b));}
template<typename T>inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {return modpow(b, Mod - 2, Mod );}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}
int e1 , e2 , d1 ;
template < typename T >inline void extgcd(T a , T b){
    if(!b) {e1 = 1 , e2 = 0 , d1 = a ; return ;}
    extgcd(b , a % b) ;
    T x1 = e2 ;
    T y1 = e1 - (a / b) * e2 ;
    e1 = x1 ;
    e2 = y1 ;
}

/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
/*
std::vector<int> primes;
bitset < MAX_N > bs;
ll sieve_size = MAX_N ;

void sieve(ll n){
    bs.set() ;
    bs[0] = bs[1] = 1 ;
    for(ll i = 2 ; i <= n ; i++)if(bs[i]){
        for(ll j = i * i ; j <= n ; j += i) bs[j] = 0 ;
            primes.push_back((int)i);
    }
}

bool isprime(ll n){
    if(n <= sieve_size)return bs[n] ;
    for(int i = 0 ; i <= (int)primes.size() ; i++){
        if(n % primes[i] == 0)return false ;
    }
    return true ;
}

int numDiffPf[MAX_N] ;

void DiffPF(){
    for(int i = 2 ; i < MAX_N ; i++){
        if(numDiffPf[i] == 0){
            for(int j = i ; j < MAX_N ; j += i)numDiffPf[j]++;
        }
    }
}

int Phi[MAX_N] ;

void EulerPHI(){
    for(int i = 1 ; i < MAX_N ; i++)Phi[i] = i ;
        for(int i = 2 ; i < MAX_N ; i++)
            if(Phi[i] == i)
                for(int j = i ; j < MAX_N ; j += i)
                    Phi[j] = (Phi[j]/i) * (i - 1) ;
}

int F(int x){
    return 0 ;
}
pair < int , int > floydCycle(int x0){
    int tor = F(x0) , hare = F(F(x0)) ;
    while(tor != hare){tor = F(tor) , hare = F(F(hare));}
    int mu = 0 ; hare = x0 ;
    while(tor != hare){tor = F(tor) , hare = F(hare); mu++ ;}
    int lambda = 1 ; hare = F(tor) ;
    while(tor != hare){hare = F(hare) ; lambda++;}
    return {mu , lambda} ;
}
*/
template <typename T>inline vector< T > Unique(vector< T > v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t = 1 , tc = 0 ;
    while(t--) {
        int n = Int ;
        getchar() ;
        char s[n + 2] ;
        scanf("%s", s + 1) ;
        std::vector< int > f(25 , 0);
        for(int i = 1 ; i <= n ; i++){
            f[s[i] - 'A']++;
        }
        int mx = 0 , tot = 0 ;
        for(int i = 0 ; i <= 25 ; i++){
            if(f[i]){
                if(mx < f[i]){
                    mx = f[i] ;
                    tot = 1 ;
                }
                else if(mx == f[i])tot++;
            }
        }
        ll res = modpow(1LL * tot , 1LL * n , M) ;
        res %= M ;
        printf("%lld\n",res);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5 ;
const double eps = 1e-9 ;
const int MAX_N = 1e6 + 5 ;
const long long M = (long long)1e9+7 ;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) { if(a>=0) return a; return -a;}
template<typename t>inline t gcd(t a , t b) {return !b ? a : gcd(b , a % b);}
template<typename t>inline t lcm(t a , t b) {return a * ( b /gcd(a , b));}
template<typename T>inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {return modpow(b, Mod - 2, Mod );}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}
int e1 , e2 , d1 ;
template < typename T >inline void extgcd(T a , T b){
    if(!b) {e1 = 1 , e2 = 0 , d1 = a ; return ;}
    extgcd(b , a % b) ;
    T x1 = e2 ;
    T y1 = e1 - (a / b) * e2 ;
    e1 = x1 ;
    e2 = y1 ;
}

/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
/*
std::vector<int> primes;
bitset < MAX_N > bs;
ll sieve_size = MAX_N ;

void sieve(ll n){
    bs.set() ;
    bs[0] = bs[1] = 1 ;
    for(ll i = 2 ; i <= n ; i++)if(bs[i]){
        for(ll j = i * i ; j <= n ; j += i) bs[j] = 0 ;
            primes.push_back((int)i);
    }
}

bool isprime(ll n){
    if(n <= sieve_size)return bs[n] ;
    for(int i = 0 ; i <= (int)primes.size() ; i++){
        if(n % primes[i] == 0)return false ;
    }
    return true ;
}

int numDiffPf[MAX_N] ;

void DiffPF(){
    for(int i = 2 ; i < MAX_N ; i++){
        if(numDiffPf[i] == 0){
            for(int j = i ; j < MAX_N ; j += i)numDiffPf[j]++;
        }
    }
}

int Phi[MAX_N] ;

void EulerPHI(){
    for(int i = 1 ; i < MAX_N ; i++)Phi[i] = i ;
        for(int i = 2 ; i < MAX_N ; i++)
            if(Phi[i] == i)
                for(int j = i ; j < MAX_N ; j += i)
                    Phi[j] = (Phi[j]/i) * (i - 1) ;
}

int F(int x){
    return 0 ;
}
pair < int , int > floydCycle(int x0){
    int tor = F(x0) , hare = F(F(x0)) ;
    while(tor != hare){tor = F(tor) , hare = F(F(hare));}
    int mu = 0 ; hare = x0 ;
    while(tor != hare){tor = F(tor) , hare = F(hare); mu++ ;}
    int lambda = 1 ; hare = F(tor) ;
    while(tor != hare){hare = F(hare) ; lambda++;}
    return {mu , lambda} ;
}
*/
template <typename T>inline vector< T > Unique(vector< T > v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

ll F[N] ;
void fact(){
    F[0] = F[1] = 1 ;
    for(int i = 2 ; i <= N ; i++){
        F[i] = 1LL * i * F[i - 1] ;
        F[i] %= M ;
    }
}

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t = 1 , tc = 0 ;
    fact() ;
    while(t--) {
        int n = Int ;
        char s[n + 2] ;
        scanf("%s", s + 1) ;
        std::vector< int > f(25 , 0);
        for(int i = 1 ; s[i] ; i++){
            f[s[i] - 'A']++;
        }
        int mx = 0 , tot = 0 , x = 0;
        for(int i = 0 ; i <= 25 ; i++){
            if(f[i]){
                x++;
                if(mx < f[i]){
                    mx = f[i] ;
                    tot = 1 ;
                }
                else if(mx == f[i])tot++;
            }
        }
        if(tot == 1)return puts("1") , 0 ;
        else if(tot == x){
            ll k = F[n] ;
            ll de = 1LL;
            while(tot--){
                de *= F[f[0]];
                de %= M ;
            }
            //error(k , de)
            k = k * ModInv(de , M) ;
            k %= M ;
            cout << (k + x) % M << '\n' ;
        }
        else if(x >= 3){
            if(tot <= 2){
                int re = n - (2 * mx) ;
                re = mx + re ;
                ll res = 0 ;
                for(int i = mx , j = re; i <= j ; i++ , j--){
                    ll k = F[n] ;
                    ll h = F[i] * F[j] ;
                    h %= M ;
                    k = k * ModInv(h , M) ;
                    k %= M ;
                    k *= 2LL ;
                    res += k ;
                    res %= M ;
                }
                res += tot ;
                res %= M ;
                cout << res << '\n' ;
            }
            else if(tot == 3 and x == 4){
                int re = n - (3 * mx) ;
                re = mx + re ;
                ll res = 0 ;
                for(int i = mx , j = re; i <= j ; i++ , j--){
                    ll k = F[n] ;
                    ll h = F[i] * F[j] ;
                    h %= M ;
                    k = k * ModInv(h , M) ;
                    k %= M ;
                    k *= 3LL ;
                    res += k ;
                    res %= M ;
                    k = F[n] ;
                    h *= F[mx] ;
                    k = k * ModInv(h , M) ;
                    k %= M ;
                    k *= 3LL ;
                    k %= M ;
                    res += k ;
                    res %= M ;
                }
                res += tot ;
                res %= M ;
                cout << res << '\n' ;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5 ;
const double eps = 1e-9 ;
const int MAX_N = 1e6 + 5 ;
const long long M = (long long)1e9+7 ;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) { if(a>=0) return a; return -a;}
template<typename t>inline t gcd(t a , t b) {return !b ? a : gcd(b , a % b);}
template<typename t>inline t lcm(t a , t b) {return a * ( b /gcd(a , b));}
template<typename T>inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {return modpow(b, Mod - 2, Mod );}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}
int e1 , e2 , d1 ;
template < typename T >inline void extgcd(T a , T b){
    if(!b) {e1 = 1 , e2 = 0 , d1 = a ; return ;}
    extgcd(b , a % b) ;
    T x1 = e2 ;
    T y1 = e1 - (a / b) * e2 ;
    e1 = x1 ;
    e2 = y1 ;
}

/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
/*
std::vector<int> primes;
bitset < MAX_N > bs;
ll sieve_size = MAX_N ;

void sieve(ll n){
    bs.set() ;
    bs[0] = bs[1] = 1 ;
    for(ll i = 2 ; i <= n ; i++)if(bs[i]){
        for(ll j = i * i ; j <= n ; j += i) bs[j] = 0 ;
            primes.push_back((int)i);
    }
}

bool isprime(ll n){
    if(n <= sieve_size)return bs[n] ;
    for(int i = 0 ; i <= (int)primes.size() ; i++){
        if(n % primes[i] == 0)return false ;
    }
    return true ;
}

int numDiffPf[MAX_N] ;

void DiffPF(){
    for(int i = 2 ; i < MAX_N ; i++){
        if(numDiffPf[i] == 0){
            for(int j = i ; j < MAX_N ; j += i)numDiffPf[j]++;
        }
    }
}

int Phi[MAX_N] ;

void EulerPHI(){
    for(int i = 1 ; i < MAX_N ; i++)Phi[i] = i ;
        for(int i = 2 ; i < MAX_N ; i++)
            if(Phi[i] == i)
                for(int j = i ; j < MAX_N ; j += i)
                    Phi[j] = (Phi[j]/i) * (i - 1) ;
}

int F(int x){
    return 0 ;
}
pair < int , int > floydCycle(int x0){
    int tor = F(x0) , hare = F(F(x0)) ;
    while(tor != hare){tor = F(tor) , hare = F(F(hare));}
    int mu = 0 ; hare = x0 ;
    while(tor != hare){tor = F(tor) , hare = F(hare); mu++ ;}
    int lambda = 1 ; hare = F(tor) ;
    while(tor != hare){hare = F(hare) ; lambda++;}
    return {mu , lambda} ;
}
*/
template <typename T>inline vector< T > Unique(vector< T > v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t = 1 , tc = 0 ;
    while(t--) {
        int n = Int ;
        char s[n + 2] ;
        scanf("%s", s + 1) ;
        std::vector< int > f(25 , 0);
        for(int i = 1 ; s[i] ; i++){
            f[s[i] - 'A']++;
        }
        int mx = 0 , tot = 0 ;
        for(int i = 0 ; i <= 25 ; i++){
            if(f[i]){
                if(mx < f[i]){
                    mx = f[i] ;
                    tot = 1 ;
                }
                else if(mx == f[i])tot++;
            }
        }
        ll res = modpow(1LL * tot , 1LL * n , M) ;
        cout << res % M << '\n' ;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5 ;
const double eps = 1e-9 ;
const int MAX_N = 1e6 + 5 ;
const long long M = (long long)1e9+7 ;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) { if(a>=0) return a; return -a;}
template<typename t>inline t gcd(t a , t b) {return !b ? a : gcd(b , a % b);}
template<typename t>inline t lcm(t a , t b) {return a * ( b /gcd(a , b));}
template<typename T>inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {return modpow(b, Mod - 2, Mod );}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}
int e1 , e2 , d1 ;
template < typename T >inline void extgcd(T a , T b){
    if(!b) {e1 = 1 , e2 = 0 , d1 = a ; return ;}
    extgcd(b , a % b) ;
    T x1 = e2 ;
    T y1 = e1 - (a / b) * e2 ;
    e1 = x1 ;
    e2 = y1 ;
}

/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
/*
std::vector<int> primes;
bitset < MAX_N > bs;
ll sieve_size = MAX_N ;

void sieve(ll n){
    bs.set() ;
    bs[0] = bs[1] = 1 ;
    for(ll i = 2 ; i <= n ; i++)if(bs[i]){
        for(ll j = i * i ; j <= n ; j += i) bs[j] = 0 ;
            primes.push_back((int)i);
    }
}

bool isprime(ll n){
    if(n <= sieve_size)return bs[n] ;
    for(int i = 0 ; i <= (int)primes.size() ; i++){
        if(n % primes[i] == 0)return false ;
    }
    return true ;
}

int numDiffPf[MAX_N] ;

void DiffPF(){
    for(int i = 2 ; i < MAX_N ; i++){
        if(numDiffPf[i] == 0){
            for(int j = i ; j < MAX_N ; j += i)numDiffPf[j]++;
        }
    }
}

int Phi[MAX_N] ;

void EulerPHI(){
    for(int i = 1 ; i < MAX_N ; i++)Phi[i] = i ;
        for(int i = 2 ; i < MAX_N ; i++)
            if(Phi[i] == i)
                for(int j = i ; j < MAX_N ; j += i)
                    Phi[j] = (Phi[j]/i) * (i - 1) ;
}

int F(int x){
    return 0 ;
}
pair < int , int > floydCycle(int x0){
    int tor = F(x0) , hare = F(F(x0)) ;
    while(tor != hare){tor = F(tor) , hare = F(F(hare));}
    int mu = 0 ; hare = x0 ;
    while(tor != hare){tor = F(tor) , hare = F(hare); mu++ ;}
    int lambda = 1 ; hare = F(tor) ;
    while(tor != hare){hare = F(hare) ; lambda++;}
    return {mu , lambda} ;
}
*/
template <typename T>inline vector< T > Unique(vector< T > v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

ll F[N] ;
void fact(){
    F[0] = F[1] = 1 ;
    for(int i = 2 ; i <= N ; i++){
        F[i] = 1LL * i * F[i - 1] ;
        F[i] %= M ;
    }
}

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t = 1 , tc = 0 ;
    fact() ;
    while(t--) {
        int n = Int ;
        char s[n + 2] ;
        scanf("%s", s + 1) ;
        std::vector< int > f(25 , 0);
        for(int i = 1 ; s[i] ; i++){
            f[s[i] - 'A']++;
        }
        int mx = 0 , tot = 0 , x = 0;
        for(int i = 0 ; i <= 25 ; i++){
            if(f[i]){
                x++;
                if(mx < f[i]){
                    mx = f[i] ;
                    tot = 1 ;
                }
                else if(mx == f[i])tot++;
            }
        }
        if(tot == 1)return puts("1") , 0 ;
        else if(tot == x){
            ll k = F[n] ;
            ll de = 1LL;
            while(tot--){
                de *= F[f[0]];
                de %= M ;
            }
            k = k * ModInv(de , M) ;
            k %= M ;
            cout << (k + x) % M << '\n' ;
        }
        else if(x >= 3){
            if(tot <= 2){
                int re = n - (2 * mx) ;
                re = mx + re ;
                ll res = 0 ;
                for(int i = mx , j = re; i <= j ; i++ , j--){
                    ll k = F[n] ;
                    ll h = F[i] * F[j] ;
                    h %= M ;
                    k = k * ModInv(h , M) ;
                    k %= M ;
                    k *= 2LL ;
                    res += k ;
                    res %= M ;
                }
                res += tot ;
                res %= M ;
                cout << res << '\n' ;
            }
            else if(tot == 3 and x == 4){
                int re = n - (3 * mx) ;
                re = mx + re ;
                ll res = 0 ;
                for(int i = mx , j = re; i <= j ; i++ , j--){
                    ll k = F[n] ;
                    ll h = F[i] * F[j] ;
                    h %= M ;
                    k = k * ModInv(h , M) ;
                    k %= M ;
                    k *= 3LL ;
                    res += k ;
                    res %= M ;
                    k = F[n] ;
                    h *= F[mx] ;
                    k = k * ModInv(h , M) ;
                    k %= M ;
                    k *= 3LL ;
                    k %= M ;
                    res += k ;
                    res %= M ;
                }
                res += tot ;
                res %= M ;
                cout << res << '\n' ;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5 ;
const double eps = 1e-9 ;
const int MAX_N = 1e6 + 5 ;
const long long M = (long long)1e9+7 ;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) { if(a>=0) return a; return -a;}
template<typename t>inline t gcd(t a , t b) {return !b ? a : gcd(b , a % b);}
template<typename t>inline t lcm(t a , t b) {return a * ( b /gcd(a , b));}
template<typename T>inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {return modpow(b, Mod - 2, Mod );}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}
int e1 , e2 , d1 ;
template < typename T >inline void extgcd(T a , T b){
    if(!b) {e1 = 1 , e2 = 0 , d1 = a ; return ;}
    extgcd(b , a % b) ;
    T x1 = e2 ;
    T y1 = e1 - (a / b) * e2 ;
    e1 = x1 ;
    e2 = y1 ;
}

/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
/*
std::vector<int> primes;
bitset < MAX_N > bs;
ll sieve_size = MAX_N ;

void sieve(ll n){
    bs.set() ;
    bs[0] = bs[1] = 1 ;
    for(ll i = 2 ; i <= n ; i++)if(bs[i]){
        for(ll j = i * i ; j <= n ; j += i) bs[j] = 0 ;
            primes.push_back((int)i);
    }
}

bool isprime(ll n){
    if(n <= sieve_size)return bs[n] ;
    for(int i = 0 ; i <= (int)primes.size() ; i++){
        if(n % primes[i] == 0)return false ;
    }
    return true ;
}

int numDiffPf[MAX_N] ;

void DiffPF(){
    for(int i = 2 ; i < MAX_N ; i++){
        if(numDiffPf[i] == 0){
            for(int j = i ; j < MAX_N ; j += i)numDiffPf[j]++;
        }
    }
}

int Phi[MAX_N] ;

void EulerPHI(){
    for(int i = 1 ; i < MAX_N ; i++)Phi[i] = i ;
        for(int i = 2 ; i < MAX_N ; i++)
            if(Phi[i] == i)
                for(int j = i ; j < MAX_N ; j += i)
                    Phi[j] = (Phi[j]/i) * (i - 1) ;
}

int F(int x){
    return 0 ;
}
pair < int , int > floydCycle(int x0){
    int tor = F(x0) , hare = F(F(x0)) ;
    while(tor != hare){tor = F(tor) , hare = F(F(hare));}
    int mu = 0 ; hare = x0 ;
    while(tor != hare){tor = F(tor) , hare = F(hare); mu++ ;}
    int lambda = 1 ; hare = F(tor) ;
    while(tor != hare){hare = F(hare) ; lambda++;}
    return {mu , lambda} ;
}
*/
template <typename T>inline vector< T > Unique(vector< T > v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t = 1 , tc = 0 ;
    while(t--) {
        int n = Int ;
        getchar() ;
        char s[n + 2] ;
        scanf("%s", s + 1) ;
        std::vector< int > f(25 , 0);
        for(int i = 1 ; s[i] ; i++){
            f[s[i] - 'A']++;
        }
        int mx = 0 , tot = 0 ;
        for(int i = 0 ; i <= 25 ; i++){
            if(f[i]){
                if(mx < f[i]){
                    mx = f[i] ;
                    tot = 1 ;
                }
                else if(mx == f[i])tot++;
            }
        }
        ll res = modpow(1LL * tot , 1LL * n , M) ;
        res %= M ;
        printf("%lld\n",res);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5 ;
const double eps = 1e-9 ;
const int MAX_N = 1e6 + 5 ;
const long long M = (long long)1e9+7 ;
#define     ll      long long
#define     ull     unsigned long long
int Int() {
    int x;
    scanf("%d",&x);
    return x;
}
ll Long() {
    ll x;
    scanf("%lld",&x);
    return x;
}
void Char(char* ch) {
    scanf("%s",ch);
}
template<typename t>inline t abs(t a) { if(a>=0) return a; return -a;}
template<typename t>inline t gcd(t a , t b) {return !b ? a : gcd(b , a % b);}
template<typename t>inline t lcm(t a , t b) {return a * ( b /gcd(a , b));}
template<typename T>inline T modpow(T b, T p, T Mod) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
            res %= Mod ;
        }
        b *= b;
        b %= Mod;
        p >>= 1;
    }
    return res ;
}

template<typename T> inline T ModInv(T b, T Mod) {return modpow(b, Mod - 2, Mod );}

template<typename T> inline T pwr(T b, T p) {
    T res  = 1;
    while(p) {
        if(p&1) {
            res *= b ;
        }
        b *= b;
        p >>= 1;
    }
    return res ;
}
int e1 , e2 , d1 ;
template < typename T >inline void extgcd(T a , T b){
    if(!b) {e1 = 1 , e2 = 0 , d1 = a ; return ;}
    extgcd(b , a % b) ;
    T x1 = e2 ;
    T y1 = e1 - (a / b) * e2 ;
    e1 = x1 ;
    e2 = y1 ;
}

/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
/*
std::vector<int> primes;
bitset < MAX_N > bs;
ll sieve_size = MAX_N ;

void sieve(ll n){
    bs.set() ;
    bs[0] = bs[1] = 1 ;
    for(ll i = 2 ; i <= n ; i++)if(bs[i]){
        for(ll j = i * i ; j <= n ; j += i) bs[j] = 0 ;
            primes.push_back((int)i);
    }
}

bool isprime(ll n){
    if(n <= sieve_size)return bs[n] ;
    for(int i = 0 ; i <= (int)primes.size() ; i++){
        if(n % primes[i] == 0)return false ;
    }
    return true ;
}

int numDiffPf[MAX_N] ;

void DiffPF(){
    for(int i = 2 ; i < MAX_N ; i++){
        if(numDiffPf[i] == 0){
            for(int j = i ; j < MAX_N ; j += i)numDiffPf[j]++;
        }
    }
}

int Phi[MAX_N] ;

void EulerPHI(){
    for(int i = 1 ; i < MAX_N ; i++)Phi[i] = i ;
        for(int i = 2 ; i < MAX_N ; i++)
            if(Phi[i] == i)
                for(int j = i ; j < MAX_N ; j += i)
                    Phi[j] = (Phi[j]/i) * (i - 1) ;
}

int F(int x){
    return 0 ;
}
pair < int , int > floydCycle(int x0){
    int tor = F(x0) , hare = F(F(x0)) ;
    while(tor != hare){tor = F(tor) , hare = F(F(hare));}
    int mu = 0 ; hare = x0 ;
    while(tor != hare){tor = F(tor) , hare = F(hare); mu++ ;}
    int lambda = 1 ; hare = F(tor) ;
    while(tor != hare){hare = F(hare) ; lambda++;}
    return {mu , lambda} ;
}
*/
template <typename T>inline vector< T > Unique(vector< T > v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    return v;
}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
///error///
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s,char c) {
    vector<string>v;
    stringstream ss(s);
    string x;
    while(getline(ss,x,c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T,typename... Args>
void err(vector<string>::iterator it,T a,Args...args) {
    cout<<it->substr((*it)[0]==' ',it->length())<< " = " << a << " ";
    err(++it,args...);
}
///This DEBUGGER-tool need c++11///
#define     Int         Int()
#define     Long        Long()
#define     pii         pair<int,int>
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     all(x)      x.begin(),x.end()
#define     mem(a)      memset(a,0,sizeof a)
#define     memn(a)     memset(a,-1,sizeof a)

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t = 1 , tc = 0 ;
    while(t--) {
        int n = Int ;
        char s[n + 2] ;
        scanf("%s", s + 1) ;
        std::vector< int > f(25 , 0);
        for(int i = 1 ; s[i] ; i++){
            f[s[i] - 'A']++;
        }
        int mx = 0 , tot = 0 ;
        for(int i = 0 ; i <= 25 ; i++){
            if(f[i]){
                if(mx < f[i]){
                    mx = f[i] ;
                    tot = 1 ;
                }
                else if(mx == f[i])tot++;
            }
        }
        ll res = modpow(1LL * tot , 1LL * n , M) ;
        res %= M ;
        cout << res << '\n' ;
    }
    return 0;
}


#include <bits/stdc++.h>
#define lli long long int
#define rep(i,n) for(lli i = 0; i < n; i++)
#define reps(i,a,n) for(lli i = a; i < n; i++)
#define reps1(i,a,n) for(int i = a; i>=n; i--)
#define s(n) cin >> n
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rsz(x,n) x.clear(); x.resize(n)
#define rrsz(x,a,n) x.clear(); x.resize(n,a)
#define wt while(true)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ls(x) ((2*(x)) + 1)
#define rs(x) ((ls(x)) + 1)
#define md(a,b) (((a) + (b))/2)
#define INF (1e9 + 7)
using namespace std;
vector<lli> primes;
void Sieve(lli n)
{
    vector<bool>prime(n+1,true);
    for(lli p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (lli i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (lli p=2; p<=n; p++)
       if (prime[p])
          primes.push_back(p);
}
/*Query Function*/
/*lli build(lli index,lli l,lli r,vector<lli>&nodes)
{
    if(l==r)
    return nodes[index]=a[l];
    lli mid=l+r;
    mid/=2;
    nodes[index]=min(build(2*index,l,mid,nodes),build(2*index+1,mid+1,r,nodes));
    return nodes[index];
}*/
/*For finding nearest value lesser than given value*/
/*lli query(lli index,lli l,lli r,lli cl,lli cr,lli val,vector<lli>&nodes)
{
    if(cl>r||cr<l)
    return 0;
    if(l==r)
    {
    if(nodes[index]<val)
    return l;
    else
    return 0;
    }
    lli mid=l+r;
    mid/=2;
    if(cl<=l&&r<=cr)
    {
        if(nodes[2*index+1]<val){
        return query(2*index+1,mid+1,r,cl,cr,val,nodes);}
        else if(nodes[2*index]<val)/*cout<<"a";
        return query(2*index,l,mid,cl,cr,val,nodes);
        else
        return 0;
    }
    return max(query(2*index+1,mid+1,r,cl,cr,val,nodes),query(2*index,l,mid,cl,cr,val,nodes));

}*/
/*finding nearest position upto which it is greater than or equal to*/
/*lli query1(lli index,lli l,lli r,lli cl,lli cr,lli val,lli c[])
{

    if(l>cr||cl>r)
    return 0;
    if(l==r)
    {
        if(c[index]>val)
        return r;
        else
        return 0;
    }
    lli mid=(l+r)/2;
    if(cl<=l&&r<=cr){
    if(c[2*index+1]>val)
    return query1(2*index+1,mid+1,r,cl,cr,val,c);
    else if(c[2*index]>val)
    return query1(2*index,l,mid,cl,cr,val,c);
    else
    return 0;}
    return max(query1(2*index,l,mid,cl,cr,val,c),query1(2*index+1,mid+1,r,cl,cr,val,c));
}*/
lli modd=1000000007;
int main()
{
    lli n;
    s(n);
    string q;
    s(q);
    map<char,lli>mp;
    rep(i,q.size())
    mp[q[i]]++;
    vector<lli>a(4);
    a[0]=mp['T'];
    a[1]=mp['C'];
    a[2]=mp['G'];
    a[3]=mp['A'];
    sort(a.begin(),a.end());
    if(a[3]>a[2])
    {
    cout<<1;
    return 0;
    }
    else if(a[2]>a[1])
    {
    lli ans=1;
    rep(i,n)
    {
        ans*=2;
        ans%=modd;
    }
    cout<<ans;
    return 0;
    }
    else if(a[1]>a[0])
    {
    lli ans=1;
    rep(i,n)
    {
    ans*=3;
    ans%=modd;
    }
    cout<<ans;
    return 0;
    }
    else
    {
    lli ans=1;
    rep(i,n)
    {
    ans*=4;
    ans%=modd;
    }
    cout<<ans;
    }
    return 0;
}


#include <bits/stdc++.h>
#define lli int
#define rep(i,n) for(lli i = 0; i < n; i++)
#define reps(i,a,n) for(lli i = a; i < n; i++)
#define reps1(i,a,n) for(int i = a; i>=n; i--)
#define s(n) cin >> n
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rsz(x,n) x.clear(); x.resize(n)
#define rrsz(x,a,n) x.clear(); x.resize(n,a)
#define wt while(true)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ls(x) ((2*(x)) + 1)
#define rs(x) ((ls(x)) + 1)
#define md(a,b) (((a) + (b))/2)
#define INF (1e9 + 7)
using namespace std;
vector<lli> primes;
void Sieve(lli n)
{
    vector<bool>prime(n+1,true);
    for(lli p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (lli i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (lli p=2; p<=n; p++)
       if (prime[p])
          primes.push_back(p);
}
/*Query Function*/
/*lli build(lli index,lli l,lli r,vector<lli>&nodes)
{
    if(l==r)
    return nodes[index]=a[l];
    lli mid=l+r;
    mid/=2;
    nodes[index]=min(build(2*index,l,mid,nodes),build(2*index+1,mid+1,r,nodes));
    return nodes[index];
}*/
/*For finding nearest value lesser than given value*/
/*lli query(lli index,lli l,lli r,lli cl,lli cr,lli val,vector<lli>&nodes)
{
    if(cl>r||cr<l)
    return 0;
    if(l==r)
    {
    if(nodes[index]<val)
    return l;
    else
    return 0;
    }
    lli mid=l+r;
    mid/=2;
    if(cl<=l&&r<=cr)
    {
        if(nodes[2*index+1]<val){
        return query(2*index+1,mid+1,r,cl,cr,val,nodes);}
        else if(nodes[2*index]<val)/*cout<<"a";
        return query(2*index,l,mid,cl,cr,val,nodes);
        else
        return 0;
    }
    return max(query(2*index+1,mid+1,r,cl,cr,val,nodes),query(2*index,l,mid,cl,cr,val,nodes));

}*/
/*finding nearest position upto which it is greater than or equal to*/
/*lli query1(lli index,lli l,lli r,lli cl,lli cr,lli val,lli c[])
{

    if(l>cr||cl>r)
    return 0;
    if(l==r)
    {
        if(c[index]>val)
        return r;
        else
        return 0;
    }
    lli mid=(l+r)/2;
    if(cl<=l&&r<=cr){
    if(c[2*index+1]>val)
    return query1(2*index+1,mid+1,r,cl,cr,val,c);
    else if(c[2*index]>val)
    return query1(2*index,l,mid,cl,cr,val,c);
    else
    return 0;}
    return max(query1(2*index,l,mid,cl,cr,val,c),query1(2*index+1,mid+1,r,cl,cr,val,c));
}*/
lli modd=1000000007;
int main()
{
    lli n;
    s(n);
    string q;
    s(q);
    map<char,lli>mp;
    rep(i,q.size())
    mp[q[i]]++;
    vector<lli>a(4);
    a[0]=mp['T'];
    a[1]=mp['C'];
    a[2]=mp['G'];
    a[3]=mp['A'];
    sort(a.begin(),a.end());
    if(a[3]>a[2])
    {
    cout<<1;
    return 0;
    }
    else if(a[2]>a[1])
    {
    lli ans=1;
    rep(i,n)
    {
        ans*=2;
        ans%=modd;
    }
    cout<<ans;
    return 0;
    }
    else if(a[1]>a[0])
    {
    lli ans=1;
    rep(i,n)
    {
    ans*=3;
    ans%=modd;
    }
    cout<<ans;
    return 0;
    }
    else
    {
    lli ans=1;
    rep(i,n)
    {
    ans*=4;
    ans%=modd;
    }
    cout<<ans;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int main()
{
ll n;
cin>>n;
string s;
cin>>s;
ll i;
ll cnt[26]={0};
for(i=0;i<n;i++)
{
 cnt[s[i]-'A']++;
}
ll sum=0;
for(i=0;i<26;i++)
{
  if(cnt[i]>0)sum++;
}
//cout<<sum<<"\n";
if(sum==1)
{
  cout<<"1";return 0;
}
cout<<power(2,sum,mod);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int a[26];
int main()
{
   int num;
    string str;
    cin>>num;
    cin>>str;
    int mx=0;
    for(int i=0;i<num;i++){
        a[str[i]-'A']++;
        mx=max(mx,a[str[i]-'A']);
    }
    ll count=0;
    for(int i=0;i<26;i++){
        if(a[i]==mx){
            count++;
        }
    }
    ll ans=1;
    for(int i=1;i<=num;i++){
        ans=(ans*count)%mod;
           }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int main()
{
ll n;
cin>>n;
string s;
cin>>s;
ll i;
ll cnt[26]={0};
for(i=0;i<n;i++)
{
 cnt[s[i]-'A']++;
}
ll sum=0;
for(i=0;i<26;i++)
{
  if(cnt[i]>0)sum++;
}
//cout<<sum<<"\n";
if(sum==1)
{
  cout<<"1";return 0;
}
cout<<power(sum,sum,mod);
}


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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll N = 100005;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll dx[4] = {1,0,-1,0};
const ll dy[4] = {0,1,0,-1};

ll power(ll a,ll n,ll m=M){
    ll ans=1;
    while(n){
        if(n&1) ans=ans*a;
        a=a*a;
        n=n>>1;
        ans=ans%m;
        a=a%m;
    }
    return ans;
}

ll fact[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    string s;
    cin>>n>>s;
    ll A[4]={0};
    fact[0]=1;
    rep(i,1,N)	fact[i] = (fact[i-1]*i)%M;
    rep(i,0,n){
    	if(s[i]=='A')	A[0]++;
    	if(s[i]=='C')	A[1]++;
    	if(s[i]=='G')	A[2]++;
    	if(s[i]=='T')	A[3]++;
    }
    sort(A,A+4);
    ll B[4]={0},C[4]={0};
    ll cur=0;
    B[cur]=A[0];C[cur]=1;
    rep(i,1,4){
    	if(A[i]==A[i-1])	B[cur]+=A[i],C[cur]++;
    	else cur++,B[cur]=A[i],C[cur]=1;
    }
    ll ans=fact[n];
    // rep(i,0,4)	cout<<B[i]<<" ";cout<<endl;
    // rep(i,0,4)	cout<<C[i]<<" ";cout<<endl;
    rep(i,0,cur+1){
    	ans = (ans * power(C[i],B[i]))%M;
    	ans = (ans * power(fact[B[i]],M-2))%M;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll N = 100005;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll dx[4] = {1,0,-1,0};
const ll dy[4] = {0,1,0,-1};

ll power(ll a,ll n,ll m=M){
    ll ans=1;
    while(n){
        if(n&1) ans=ans*a;
        a=a*a;
        n=n>>1;
        ans=ans%m;
        a=a%m;
    }
    return ans;
}

ll fact[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    string s;
    cin>>n>>s;
    ll A[4]={0};
    fact[0]=1;
    rep(i,1,N)	fact[i] = (fact[i-1]*i)%M;
    rep(i,0,n){
    	if(s[i]=='A')	A[0]++;
    	if(s[i]=='C')	A[1]++;
    	if(s[i]=='G')	A[2]++;
    	if(s[i]=='T')	A[3]++;
    }
    sort(A,A+4);
    ll C[4]={0};
    ll cur=0;
    C[cur]=1;
    rep(i,1,4){
    	if(A[i]==A[i-1])	C[cur]++;
    	else cur++,C[cur]=1;
    }
    ll ans = power(C[cur],n);
    cout<<ans<<endl;
    return 0;
}


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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll N = 100005;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll dx[4] = {1,0,-1,0};
const ll dy[4] = {0,1,0,-1};

ll power(ll a,ll n,ll m=M){
    ll ans=1;
    while(n){
        if(n&1) ans=ans*a;
        a=a*a;
        n=n>>1;
        ans=ans%m;
        a=a%m;
    }
    return ans;
}

ll fact[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    fact[0]=1;
    rep(i,1,N)	fact[i] = (fact[i-1]*i)%M;
    ll A[26]={0};
    rep(i,0,n){
    	A[s[i]-'A']++;
    }
    ll ans = fact[n];
    rep(i,0,26){
 	  	ans = (ans * power(fact[A[i]],M-2))%M;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll N = 100005;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll dx[4] = {1,0,-1,0};
const ll dy[4] = {0,1,0,-1};

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll A[26]={0};
    rep(i,0,n){
    	A[s[i]-'A']++;
    }
    ll ans=0;
    rep(i,0,26){
    	ans = (ans + (A[i]*A[i]*n)%M)%M;
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(n);i++)
#define fori(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);

#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;

int pow(int x, unsigned int y, int p)
{
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

//AGCGAATCCCATTGT
//AAAAGGGTTTTCCCC

int main(){
	llint n;
	string s;
	cin>>n>>s;
	map <char, llint> m;
	llint mx = 0;
	for(auto i : s){ m[i]++; mx = max(mx, m[i]); }
	llint k = 0;
	for(auto it = m.begin(); it != m.end(); it++) if(it->sec == mx) k += 1;
	//debug(k);
	//cout<<pow(3, 15)<<endl;
	cout<<pow(k, n, MOD);
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(n);i++)
#define fori(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);

#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;

llint pow(llint x,  llint y, llint p)
{
    llint res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

//AGCGAATCCCATTGT
//AAAAGGGTTTTCCCC

int main(){
	llint n;
	string s;
	cin>>n>>s;
	map <char, llint> m;
	llint mx = 0;
	for(auto i : s){ m[i]++; mx = max(mx, m[i]); }
	llint k = 0;
	for(auto it = m.begin(); it != m.end(); it++) if(it->sec == mx) k += 1;
	//debug(k);
	//cout<<pow(3, 15)<<endl;
	cout<<pow(k, n, MOD);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int kModulo = 1000000007;

int main()
{
	int n, ctr[4] = {0, 0, 0, 0};
	string s;
	cin >> n >> s;
	for (auto c : s) {
		if (c == 'C') ++ctr[0];
		else if (c == 'A') ++ctr[1];
		else if (c == 'G') ++ctr[2];
		else if (c == 'T') ++ctr[3];
	}
	sort(ctr, ctr + 4);
	int k = 1;
	for (int i = 2; i >= 0; ++i) {
		if (ctr[i] == ctr[i + 1]) {
			++k;
		} else break;
	}
	int r = 1;
	for (int i = 0; i < n; ++i) {
		r = (r * k) % kModulo;
	}
	cout << r << '\n';
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const long long kModulo = 1000000007;

int main()
{
	int n;
	long long ctr[4] = {0, 0, 0, 0};
	string s;
	cin >> n >> s;
	for (auto c : s) {
		if (c == 'C') ++ctr[0];
		else if (c == 'A') ++ctr[1];
		else if (c == 'G') ++ctr[2];
		else if (c == 'T') ++ctr[3];
	}
	sort(ctr, ctr + 4);
	long long k = 1;
	for (int i = 2; i >= 0; --i) {
		if (ctr[i] == ctr[i + 1]) {
			++k;
		} else break;
	}
	long long r = 1;
	for (int i = 0; i < n; ++i) {
		r = (r * k) % kModulo;
	}
	cout << r << '\n';
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int kModulo = 1000000007;

int main()
{
	int n, ctr[4] = {0, 0, 0, 0};
	string s;
	cin >> n >> s;
	for (auto c : s) {
		if (c == 'C') ++ctr[0];
		else if (c == 'A') ++ctr[1];
		else if (c == 'G') ++ctr[2];
		else if (c == 'T') ++ctr[3];
	}
	sort(ctr, ctr + 4);
	int k = 1;
	for (int i = 2; i >= 0; --i) {
		if (ctr[i] == ctr[i + 1]) {
			++k;
		} else break;
	}
	int r = 1;
	for (int i = 0; i < n; ++i) {
		r = (r * k) % kModulo;
	}
	cout << r << '\n';
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const long long kModulo = 1000000007;

int main()
{
	int n;
	long long ctr[4] = {0, 0, 0, 0};
	string s;
	cin >> n >> s;
	for (auto c : s) {
		if (c == 'C') ++ctr[0];
		else if (c == 'A') ++ctr[1];
		else if (c == 'G') ++ctr[2];
		else if (c == 'T') ++ctr[3];
	}
	sort(ctr, ctr + 4);
	int k = 1;
	for (int i = 2; i >= 0; --i) {
		if (ctr[i] == ctr[i + 1]) {
			++k;
		} else break;
	}
	int r = 1;
	for (int i = 0; i < n; ++i) {
		r = (r * k) % kModulo;
	}
	cout << r << '\n';
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()), ((v).end())
#define s(n) scanf("%d", &n)
#define sc(n) scanf("%c", &n)
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define ss(n) scanf("%s", n)
#define INF (int)1e9
#define EPS 1e-9
#define bitcount __builtin_popcount
#define gcd __gcd
#define n_mod(a, k) ((a % k) + k) % k
#define mod(a, k) (a % k)
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i, v) for (int i = 0; i < sz(v); ++i)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
#define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
#define LSOne(S) (S & (-S))
#define repa(v) lpi(i, 0, sz(v)) lpi(j, 0, sz(v[i]))
#define P(x) cout << #x << " = { " << x << " }\n"
#define PB push_back
#define MP make_pair
#define M_PI 3.14159265358979323846
#define fast_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define file_IO                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<string> vs;
int dcmp(double x, double y)
{
    return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}
long long POW_M(long long a, long long p, long long m = (long long)1e9 + 7LL)
{
    if (p == 0)
        return 1;
    if (p == 1)
        return a % m;
    long long x = POW_M(a, p / 2, m);
    if (p % 2 == 0)
        return ((x % m) * x) % m;
    return (((x % m) * x % m) * a) % m;
}
int n;
ll freq[26];
string input;
ll mx, cnt;
int main()
{

#ifndef ONLINE_JUDGE
    file_IO;
#else
    fast_IO;
#endif

    cin >> n;
    cin >> input;
    rep(i, input)
    {
        freq[input[i] - 'A']++;
    }
    lp(i, 26) { mx = max(mx, freq[i]); }
    lp(i, 26)
    {
        if (mx == freq[i])
            cnt++;
    }
    cout << POW_M(cnt, n) << '\n';
}


using namespace std;

#include<iostream>
#include<set>

#define ll long long
#define MOD 1000000007

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k, ans = 1;
    set<char> cset;
    string str;

    cin>>k>>str;

    for(ll i=0; i<k; i++) cset.insert(str[i]);
    n = cset.size();

    while(k--) ans = (ans*n)%MOD;
    cout<<ans;

return 0;
}


using namespace std;

#include<iostream>
#include<cmath>
#include<map>

#define ll long long
#define MOD 1000000007

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n = 0, k, ans = 1, maci = 0;
    map<char, ll> cmap;
    string str;

    cin>>k>>str;

    for(ll i=0; i<k; i++){
        cmap[str[i]]++;
        maci = max(maci, cmap[str[i]]);
    }

    for(auto it=cmap.begin(); it!=cmap.end(); it++){
        if(it->second==maci) n++;
    }

    while(k--) ans = (ans*n)%MOD;
    cout<<ans;

return 0;
}


#include <bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef double long db;
ll mod=1e9+7;
ll qpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1) res=res*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return res%mod;
}
int main(){
    ll n;cin>>n;
    string s;cin>>s;
    ll numa=0,numt=0,numg=0,numc=0;
    for(int i=0;i<n;i++){
        if(s[i]=='A') numa++;
        if(s[i]=='T') numt++;
        if(s[i]=='C') numc++;
        if(s[i]=='G') numg++;
    }
    ll mx=0,num=0;
    mx=max(max(numa,numt),max(numg,numc));
    if(numa==mx) num++;
    if(numt==mx) num++;
    if(numc==mx) num++;
    if(numg==mx) num++;
    cout<<qpow(num,n)<<endl;
}


//white_whale
#include<bits/stdc++.h>
#include<unordered_map>
#define mod 1000000007
using namespace std;

typedef long long ll;
ll solve(ll x,ll n)
{
	if(n==1)
	{
		return x%mod;
	}
	if(n%2==0)
	{
		ll tmp=solve(x,n/2);
		return (tmp%mod*tmp%mod)%mod;
	}
	return (x%mod*solve(x,n-1)%mod)%mod;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	set<char> ss;
	for(int i=0;i<n;i++)
	{
		ss.insert(s[i]);
	}
	int x=ss.size();
	ll ans=solve(x,n);
	cout<<ans<<"\n";
}


//white_whale
#include<bits/stdc++.h>
#include<unordered_map>
#define mod 1000000007
using namespace std;

typedef long long ll;
ll solve(ll x,ll n)
{
	if(n==1)
	{
		return x%mod;
	}
	if(n%2==0)
	{
		ll tmp=solve(x,n/2);
		return (tmp%mod*tmp%mod)%mod;
	}
	return (x%mod*solve(x,n-1)%mod)%mod;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int a=0,b=0,g=0,t=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='A')
			a++;
		if(s[i]=='C')
			b++;
		if(s[i]=='G')
			g++;
		if(s[i]=='T')
			t++;
	}
	int ma=max(a,max(b,max(g,t)));
	int cnt=0;
	if(a==ma)
		cnt++;
	if(b==ma)
		cnt++;
	if(g==ma)
		cnt++;
	if(t==ma)
		cnt++;
	ll ans=solve(cnt,n);
	cout<<ans<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
#define md 1000000007
int main()
{
    ios::sync_with_stdio(false);
    map<char, long long int> count;
    count['A'] = 0;
    count['C'] = 0;
    count['G'] = 0;
    count['T'] = 0;
    int n;
    char s;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
    	cin >> s;
    	count[s]++;
    }
    long long int k, noOfStrings = 1,m;
    k = max(max(count['A'], count['C']), max(count['G'], count['T']));
    m = (count['A'] == k) + (count['C'] == k) + (count['G'] == k) + (count['T'] == k);
    for (int i = 0; i < n; ++i)
    {
    	noOfStrings = (noOfStrings * m) % md;
    }
    cout << noOfStrings <<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define M 1000000007
using namespace std;
long long power(long long x,long long n)
{
    if(n==0)return 1;
    else if(n%2==0)
    {
        long long y=power(x,n/2);
        return ((y%M)*(y%M))%M;
    }
    else return ((x%M)*(power(x,n-1)%M))%M;
}
int main()
{
    long long n;
    string s;
    cin>>n>>s;
    set<char>st;
    for(long long i=0;i<n;i++)st.insert(s[i]);
    cout<<power(st.size(),n);
}


#include <iostream>
using namespace std;
const int mod=1e9 +7;
int freq[4];
int main() {
	int n,mx,coun=0;cin>>n;
	long long res=1;
	char c;
	for(int i=0;i<n;i++){
		cin>>c;
		if(c=='A')freq[0]++;
		else if(c=='C')freq[1]++;
		else if(c=='G')freq[2]++;
		else freq[3]++;
	}
	mx=max(freq[0],max(freq[1],max(freq[2],freq[3])));
	for(int i=0;i<4;i++)
		coun+=(mx==freq[i]);
	for(int i=0;i<n;i++)
		res=(res*coun)%mod;
	return cout<<res,0;
}


#include <iostream>
using namespace std;
const int mod=1e9 +7;
int freq[4];
int main() {
	int n,mx,coun=0,res=1;cin>>n;
	char c;
	for(int i=0;i<n;i++){
		cin>>c;
		if(c=='A')freq[0]++;
		else if(c=='C')freq[1]++;
		else if(c=='G')freq[2]++;
		else freq[3]++;
	}
	mx=max(freq[0],max(freq[1],max(freq[2],freq[3])));
	for(int i=0;i<4;i++)
		coun+=(mx==freq[i]);
	for(int i=0;i<n;i++)
		res=(res*coun)%mod;
	return cout<<res,0;
}


#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mod 1000000007

void powww(ll a,ll b)
{
  ll ans=1;
   //cout<<a<<" "<<b;
  while(b)
  {
    if(b&1)
    ans=((ans%mod)*(a%mod))%mod;
    b=b>>1;
    a=((a%mod)*(a%mod))%mod;
  }

  cout<<ans;
}

int main()
{
  ll n;
  string s;
  cin>>n>>s;

  map<char,ll>v;

  for(ll i=0;i<n;i++)
  {
    v[s[i]]=v[s[i]]+1;
  }
  vector<ll>vv;
  for(auto x:v)
  {
    vv.push_back(x.second);
  }

  sort(vv.begin(),vv.end(),greater<ll>());
  ll p=vv[0],cnt=1;

  for(ll i=1;i<v.size();i++)
  {
    if(vv[i]==p)
      cnt++;
  }
  //cout<<cnt;
  powww(cnt,n);

  return 0;
}


#include <bits/stdc++.h>
#define N 500050
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

ll n, m, k, a, b, cnt[200];

string s;

vector<ll> val;

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

	cin>>n;

	cin>>s;

	for(auto c: s) cnt[c] ++, k = max(k, cnt[c ]);

	const ll mod = 1000000000 + 7;

	if(cnt['A'] == k) a ++;
	if(cnt['C'] == k) a ++;
	if(cnt['G'] == k) a ++;
	if(cnt['T'] == k) a ++;

	m = 1;

	for(int i = 0; i < n; i++) m = (m*a)%mod;

	cout<<m<<"\n";
}


#include <bits/stdc++.h>
#define N 500050
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int n, m, k, a, b, cnt[200];

string s;

vector<int> val;

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

	cin>>n;

	cin>>s;

	for(auto c: s) cnt[c] ++, k = max(k, cnt[c ]);

	const int mod = 1000000000 + 7;

	if(cnt['A'] == k) a ++;
	if(cnt['C'] == k) a ++;
	if(cnt['G'] == k) a ++;
	if(cnt['T'] == k) a ++;

	m = 1;

	for(int i = 0; i < n; i++) m = (m*a)%mod;

	cout<<m<<"\n";
}


#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

const int MOD = 1e9 + 7;
const string CH = "ACGT";
int main() {
	run();
	int n;
	string s;
	cin >> n >> s;
	map<char, int> mp;
	for (auto &it : s)
		mp[it]++;
	ll ans = 1;
	int mx = 0, cnt = 0;
	for (char ch : CH) {
		if (mp[ch] > mx)
			mx = mp[ch], cnt = 1;
		else if (mp[ch] == mx)
			cnt++;
	}
	for (int i = 0; i < n; i++)
		ans = (ans * cnt) % MOD;
	cout << ans;
}


//Author - sorablaze_11
#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,n) for(int i = a; i < n ; i++)
#define per(i,a,n) for(int i = n - 1; i >= a;i--)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pb push_back
#define em emplace_back
#define mp make_pair
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ll long long int
#define ld long double

inline ll gcd(ll a,ll b) { return b ? gcd(b, a % b): a;}
inline ll fast_pow(ll a, ll b) {ll res = 1; a %= mod; assert(b >= 0); for(;b;b >>= 1){ if(b & 1) res = res * a % mod; a = a * a % mod; } return res;}
inline bool isPrime(ll a){ for(ll i = 2; i * i <= a; i++) if(a % i == 0) return 0; return 1;}

const int N = 1e5+5;
string DNA;
int A = 0, C = 0, G = 0, T = 0, n;
ll maxVal, ans = 0;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cin >> n >> DNA;
    for(int i = 0; i < DNA.size(); i++){
        if(DNA[i] == 'A') A++;
        else if(DNA[i] == 'C') C++;
        else if(DNA[i] == 'G') G++;
        else T++;
    }
    maxVal = max(A, max(C, max(G, T)));
    if(A == maxVal) ans++;
    if(C == maxVal) ans++;
    if(G == maxVal) ans++;
    if(T == maxVal) ans++;
    cout << fast_pow(ans, n) << '\n';
    return 0;
}


//Author - sorablaze_11
#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,n) for(int i = a; i < n ; i++)
#define per(i,a,n) for(int i = n - 1; i >= a;i--)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pb push_back
#define em emplace_back
#define mp make_pair
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ll long long int
#define ld long double

inline ll gcd(ll a,ll b) { return b ? gcd(b, a % b): a;}
inline ll fast_pow(ll a, ll b) {ll res = 1; a %= mod; assert(b >= 0); for(;b;b >>= 1){ if(b & 1) res = res * a % mod; a = a * a % mod; } return res;}
inline bool isPrime(ll a){ for(ll i = 2; i * i <= a; i++) if(a % i == 0) return 0; return 1;}

const int N = 1e5+5;
string DNA;
int A = 0, C = 0, G = 0, T = 0, n;
ll maxVal, ans = 0;
ll fact[N], invFact[N];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    fact[0] = invFact[0] = 1;
    for(int i = 1; i < N; i++) fact[i] = ((ll)i * fact[i - 1]) % mod;
    invFact[N - 1] = fast_pow(fact[N - 1], mod - 2) % mod;
    for(int i = N - 2; i >= 1;i--) invFact[i] = ((ll)(i + 1) * invFact[i + 1] % mod) % mod;
    cin >> n >> DNA;
    for(int i = 0; i < DNA.size(); i++){
        if(DNA[i] == 'A') A++;
        else if(DNA[i] == 'C') C++;
        else if(DNA[i] == 'G') G++;
        else T++;
    }
    maxVal = max(A, max(C, max(G, T)));
    ans = (fact[n] % mod * invFact[A] % mod) % mod;
    ans = (ans % mod * invFact[C] % mod) % mod;
    ans = (ans % mod * invFact[G] % mod) % mod;
    ans = (ans % mod * invFact[T] % mod) % mod;
    if(A + C + G + T != maxVal){
        if(maxVal == A) ans = (ans + (ll)1) % mod;
        if(maxVal == C) ans = (ans + (ll)1) % mod;
        if(maxVal == G) ans = (ans + (ll)1) % mod;
        if(maxVal == T) ans = (ans + (ll)1) % mod;
    }
    cout << ans << '\n';
    return 0;
}


# include<bits/stdc++.h>

using namespace std;

// Basic
typedef long long 		ll;
typedef long double 		ld;

// Pair
typedef pair<int, int >	   ii;
typedef pair<ll, ll>		   LL;
typedef pair<int, string >	istr;

// List
typedef vector<int >		vi;
typedef vector<vi >		vvi;
typedef vector<ll >		vll;
typedef vector<vll >    vvll;

typedef vector<ii >		vii;
typedef vector<LL >		vLL;

typedef vector<string > vstr;
typedef vector<istr>		vistr;

// Map
typedef map<ll, int > 		mpll;
typedef map<string, int>	mpstr;

// Set
typedef set<string > 		sstr;
typedef set<int >    		si;
typedef set<ii > 				sii;

// multiset
typedef multiset<int >		msi;
typedef multiset<ii >		msii;

// Stacks and Queue
typedef queue<char >       qc;
typedef queue<int >        qi;

typedef stack<char >       stc;
typedef stack<int >        sti;

// ---------------- Value Manipulators --------------------
const int    inf  = 1e9;
const double pi   = acos(-1);
const int    SLMT = 1e5 + 5;
const int    ALMT = 1e6 + 5;

# define ROUND(x)	(int)((double)x + 0.5)

//------------------ REPEAT --------------------------------
# define repf(i, a, b)	for(auto i = a; i != b; ++i)
# define repr(i, a, b)	for(auto i = a; i != b; --i)
# define repstr(i, str)	for(auto i = 0; str[i]; ++i)

// # define uDia(i, j, m, n)	repf(i,0,m) repf(j, i+1, n)
// # define lDia(i, j, m, n)	repf(i,0,m) repf(j,0,i)
// # define cMat(i, j, m, n)	repf(i,0,m)	repf(j,0,n)

// ----------------- STL -----------------------------------
# define mp(x, y)		make_pair(x, y)
# define pb(x) 		    push_back(x)
# define pob()			pop_back()
# define stlf(x)		x.begin(), x.end()
# define stlr(x)		x.rbegin(), x.rend()
# define F				first
# define S				second

// ----------------- I/O -----------------------------------
# define gc()			getchar()
# define pc(x)			putchar(x)

# define ss(str)		gets(str)
# define ps(str)		puts(str)

# define pnl			pc('\n')

# define sll(x)		sd(x)
# define pll(x)      pd(x)

template <class T >
inline void sd(T &num){

	num = 0;
	int sign = 0;
	char ch;

	while(isspace(ch = gc()));

	if(isdigit(ch))
		num = ch - '0';
	else
		sign = ch == '+' ? 0: 1;

	while(isdigit(ch = gc()))
		num = (num << 3 ) + (num << 1) + ch - '0';

	num = sign ? -num : num;
}

template <class T >
inline void pd(T num, char ch = ' '){
   if(num < 0){
     pc('-');
     num = -num;
   }

   char digits[21] = {};
   int pos = 1;

   do{
      digits[pos++] = '0' + num%10;
   }while(num /= 10);

   while(--pos)
      pc(digits[pos]);

   pc(ch);
}

# define sdbl(x)	 scanf("%f", &x)
# define pdbl(x,y)   printf("%.*f ",x,y)
# define pf(x)       printf("%f", x)

// Input int array
template <class T>
inline void iArr(T &arr, int size){
	repf(i, 0, size)
		sd(arr[i]);
}

// Input map input integers
template <class T>
inline int mArr(T &arr, int size){
   int val;
   int mval = INT_MIN;
	repf(i, 0, size)
		sd(val), ++arr[val], mval = max(mval, val);
   return mval;
}

template <class T>
inline void oArr(T &arr, int size){
	repf(i, 0, size)
		pd(arr[i]);
	pnl;
}

template <class T>
inline void iMat(T &mat, int n, int m){
	repf(i, 0, n)
		repf(j, 0, m)
			sd(mat[i][j]);
}

template <class T>
inline void oMat(T &mat, int n, int m){
	repf(i, 0, n){
		repf(j, 0, m)
			pd(mat[i][j]);
		pnl;
	}
}

// character matrix fix :
inline void oMat(char **mat, int n){
	repf(i, 0, n)
	   ps(mat[i]);
}

inline void iMat(char **mat, int n){
	repf(i, 0, n)
		ss(mat[i]);
}

# define lb		lower_bound
# define ub		upper_bound

// --------------------------------------------------
// ------------- Data Fillers -----------------------
// --------------------------------------------------

template <class T>
inline void MAT(T **&mat, int n, int m, T val = 0){
   mat = new T*[n];

   if(!val){
    repf(i, 0, n)
      mat[i] = new T[m+1]();
      return ;
   }

   repf(i, 0, n){
      mat[i] = new T[m+1];
      repf(j, 0, m+1)
         mat[i][j] = val;
   }
}

template <class T>
inline void ARR(T *&arr, int n, int val = 0){
   arr = new T[n];
   fill(arr, arr+n, val);
}

// --------------------------------------------------
// ------------ CODE MODES --------------------------
// --------------------------------------------------
# define FAST		ios_base::sync_with_stdio(false); cin.tie(0);
# define TC			int tc; sd(tc); while(tc--)

// --------------------------------------------------
// ----------------- Debugging ----------------------
// --------------------------------------------------
int debug = 0;
# define ok cout << "OK-"<< debug++ << endl;

// --------------------------------------------------
// ------------- Additional Data --------------------
// --------------------------------------------------

// ---------------------------------------------------------------
// --------------------- Support Codes	---------------------------
// ---------------------------------------------------------------

// ---------------------------------------------------------------
// ------------------------ END	---------------------------------
// ---------------------------------------------------------------

//---------------------------------------------------------------

int MOD = 1e9+7;

int bPow(int a, int n){
    int ans = 1;
    while(n){
        if(n&1)
            ans *= a, ans %= MOD;
        a *= a, a %= MOD;
        n >>= 1;
    }
    return ans;
}

int main(void){

    int n;
    sd(n);

    char *str;
    ARR(str, n+1);
    ss(str);

    int *charCnt;
    ARR(charCnt, 26);

    repstr(i, str)
        ++charCnt[str[i]-'A'];

    int mVal = *max_element(charCnt, charCnt+26);

    int k = 0;
    repstr(i, str){
        if(charCnt[str[i]-'A'] == mVal)
            ++k, charCnt[str[i]-'A'] = 0;
    }

    pd(bPow(k, n));

    return 0;
}


# include<bits/stdc++.h>

using namespace std;

// Basic
typedef long long 		ll;
typedef long double 		ld;

// Pair
typedef pair<int, int >	   ii;
typedef pair<ll, ll>		   LL;
typedef pair<int, string >	istr;

// List
typedef vector<int >		vi;
typedef vector<vi >		vvi;
typedef vector<ll >		vll;
typedef vector<vll >    vvll;

typedef vector<ii >		vii;
typedef vector<LL >		vLL;

typedef vector<string > vstr;
typedef vector<istr>		vistr;

// Map
typedef map<ll, int > 		mpll;
typedef map<string, int>	mpstr;

// Set
typedef set<string > 		sstr;
typedef set<int >    		si;
typedef set<ii > 				sii;

// multiset
typedef multiset<int >		msi;
typedef multiset<ii >		msii;

// Stacks and Queue
typedef queue<char >       qc;
typedef queue<int >        qi;

typedef stack<char >       stc;
typedef stack<int >        sti;

// ---------------- Value Manipulators --------------------
const int    inf  = 1e9;
const double pi   = acos(-1);
const int    SLMT = 1e5 + 5;
const int    ALMT = 1e6 + 5;

# define ROUND(x)	(int)((double)x + 0.5)

//------------------ REPEAT --------------------------------
# define repf(i, a, b)	for(auto i = a; i != b; ++i)
# define repr(i, a, b)	for(auto i = a; i != b; --i)
# define repstr(i, str)	for(auto i = 0; str[i]; ++i)

// # define uDia(i, j, m, n)	repf(i,0,m) repf(j, i+1, n)
// # define lDia(i, j, m, n)	repf(i,0,m) repf(j,0,i)
// # define cMat(i, j, m, n)	repf(i,0,m)	repf(j,0,n)

// ----------------- STL -----------------------------------
# define mp(x, y)		make_pair(x, y)
# define pb(x) 		    push_back(x)
# define pob()			pop_back()
# define stlf(x)		x.begin(), x.end()
# define stlr(x)		x.rbegin(), x.rend()
# define F				first
# define S				second

// ----------------- I/O -----------------------------------
# define gc()			getchar()
# define pc(x)			putchar(x)

# define ss(str)		gets(str)
# define ps(str)		puts(str)

# define pnl			pc('\n')

# define sll(x)		sd(x)
# define pll(x)      pd(x)

template <class T >
inline void sd(T &num){

	num = 0;
	int sign = 0;
	char ch;

	while(isspace(ch = gc()));

	if(isdigit(ch))
		num = ch - '0';
	else
		sign = ch == '+' ? 0: 1;

	while(isdigit(ch = gc()))
		num = (num << 3 ) + (num << 1) + ch - '0';

	num = sign ? -num : num;
}

template <class T >
inline void pd(T num, char ch = ' '){
   if(num < 0){
     pc('-');
     num = -num;
   }

   char digits[21] = {};
   int pos = 1;

   do{
      digits[pos++] = '0' + num%10;
   }while(num /= 10);

   while(--pos)
      pc(digits[pos]);

   pc(ch);
}

# define sdbl(x)	 scanf("%f", &x)
# define pdbl(x,y)   printf("%.*f ",x,y)
# define pf(x)       printf("%f", x)

// Input int array
template <class T>
inline void iArr(T &arr, int size){
	repf(i, 0, size)
		sd(arr[i]);
}

// Input map input integers
template <class T>
inline int mArr(T &arr, int size){
   int val;
   int mval = INT_MIN;
	repf(i, 0, size)
		sd(val), ++arr[val], mval = max(mval, val);
   return mval;
}

template <class T>
inline void oArr(T &arr, int size){
	repf(i, 0, size)
		pd(arr[i]);
	pnl;
}

template <class T>
inline void iMat(T &mat, int n, int m){
	repf(i, 0, n)
		repf(j, 0, m)
			sd(mat[i][j]);
}

template <class T>
inline void oMat(T &mat, int n, int m){
	repf(i, 0, n){
		repf(j, 0, m)
			pd(mat[i][j]);
		pnl;
	}
}

// character matrix fix :
inline void oMat(char **mat, int n){
	repf(i, 0, n)
	   ps(mat[i]);
}

inline void iMat(char **mat, int n){
	repf(i, 0, n)
		ss(mat[i]);
}

# define lb		lower_bound
# define ub		upper_bound

// --------------------------------------------------
// ------------- Data Fillers -----------------------
// --------------------------------------------------

template <class T>
inline void MAT(T **&mat, int n, int m, T val = 0){
   mat = new T*[n];

   if(!val){
    repf(i, 0, n)
      mat[i] = new T[m+1]();
      return ;
   }

   repf(i, 0, n){
      mat[i] = new T[m+1];
      repf(j, 0, m+1)
         mat[i][j] = val;
   }
}

template <class T>
inline void ARR(T *&arr, int n, int val = 0){
   arr = new T[n];
   fill(arr, arr+n, val);
}

// --------------------------------------------------
// ------------ CODE MODES --------------------------
// --------------------------------------------------
# define FAST		ios_base::sync_with_stdio(false); cin.tie(0);
# define TC			int tc; sd(tc); while(tc--)

// --------------------------------------------------
// ----------------- Debugging ----------------------
// --------------------------------------------------
int debug = 0;
# define ok cout << "OK-"<< debug++ << endl;

// --------------------------------------------------
// ------------- Additional Data --------------------
// --------------------------------------------------

// ---------------------------------------------------------------
// --------------------- Support Codes	---------------------------
// ---------------------------------------------------------------

// ---------------------------------------------------------------
// ------------------------ END	---------------------------------
// ---------------------------------------------------------------

//---------------------------------------------------------------

int MOD = 1e9+7;

ll bPow(ll a, int n){
    ll ans = 1;
    while(n){
        if(n&1)
            ans *= a, ans %= MOD;
        a *= a, a %= MOD;
        n >>= 1;
    }
    return ans;
}

int main(void){

    int n;
    sd(n);

    char *str;
    ARR(str, n+1);
    ss(str);

    int *charCnt;
    ARR(charCnt, 26);

    repstr(i, str)
        ++charCnt[str[i]-'A'];

    int mVal = *max_element(charCnt, charCnt+26);

    int k = 0;
    repstr(i, str){
        if(charCnt[str[i]-'A'] == mVal)
            ++k, charCnt[str[i]-'A'] = 0;
    }

    pd(bPow(k, n));

    return 0;
}


#include<iostream>
#include<string>
#include<cstring>
using namespace std;

class problem
{
public:
	void idea()
	{
		input();
		number();
		output();
	}

private:
	char c[5001];
	int n,result;

	void input()
	{
		cin>>n;
		cin>>c;
	}

	void number()
	{
		result=oss(num_max_char(),n);
	}

	int num_max_char()
	{
		int A[4]={0,0,0,0};
		for(int i=0;i<strlen(c);i++)
		{
			if(c[i]=='A') A[0]++;
			else if(c[i]=='C') A[1]++;
			else if(c[i]=='G') A[2]++;
			else if(c[i]=='T') A[3]++;
		}

		int maxx=0,count=0;
		for(int i=0;i<4;i++) if(A[i]>maxx) maxx=A[i];
		for(int i=0;i<4;i++) if(A[i]==maxx) count++;
		return count;
	}

	int oss(int x,int y)
	{
		int ans=1;
		for(int i=1;i<=y;i++) {ans*=x; ans%=1000000007;}
		return ans;
	}

	void output()
	{
		cout<<result<<endl;
	}
};

int main()
{
	problem test;
	test.idea();

	//system("pause");
	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
using namespace std;

class problem
{
public:
	void idea()
	{
		input();
		number();
		output();
	}

private:
	char c[5001];
	int n,result;
	string s;

	void input()
	{
		cin>>n;
		cin>>c;
	}

	void number()
	{
		result=oss(num_char(),n);
		one();
	}

	int num_char()
	{
		for(int i=0;i<strlen(c);i++)
		{
			int exist=0;
			for(int j=0;j<s.length();j++) if(c[i]==s.at(j)) exist=1;
			if(exist==0) s+=c[i];
		}
		return s.length();
	}

	int oss(int x,int y)
	{
		int ans=1;
		for(int i=1;i<=y;i++) {ans*=x; ans%=1000000007;}
		return ans;
	}

	void one()
	{
		int A[5]={0,0,0,0,0};
		for(int i=0;i<strlen(c);i++)
		{
			if(c[i]=='A') A[1]++;
			else if(c[i]=='C') A[2]++;
			else if(c[i]=='G') A[3]++;
			else if(c[i]=='T') A[4]++;
		}
		for(int i=1;i<=4;i++) if(A[i]>0) for(int j=1;j<=4;j++) if(A[j]>0) if(A[i]!=A[j]) result=1;
	}

	void output()
	{
		cout<<result<<endl;
	}
};

int main()
{
	problem test;
	test.idea();

	//system("pause");
	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
using namespace std;

class problem
{
public:
	void idea()
	{
		input();
		number();
		output();
	}

private:
	char *c;
	long long n,result;

	void input()
	{
		cin>>n;
		c=new char[n+1]; cin>>c;
	}

	void number()
	{
		result=oss(num_max_char(),n);
	}

	int num_max_char()
	{
		int A[4]={0,0,0,0};
		for(int i=0;i<strlen(c);i++)
		{
			if(c[i]=='A') A[0]++;
			else if(c[i]=='C') A[1]++;
			else if(c[i]=='G') A[2]++;
			else if(c[i]=='T') A[3]++;
		}

		int maxx=0,count=0;
		for(int i=0;i<4;i++) if(A[i]>maxx) maxx=A[i];
		for(int i=0;i<4;i++) if(A[i]==maxx) count++;
		return count;
	}

	long long oss(int x,int y)
	{
		long long ans=1;
		for(int i=1;i<=y;i++) {ans*=x; ans%=1000000007;}
		return ans;
	}

	void output()
	{
		cout<<result<<endl;
	}
};

int main()
{
	problem test;
	test.idea();

	//system("pause");
	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
using namespace std;

class problem
{
public:
	void idea()
	{
		input();
		number();
		output();
	}

private:
	char c[5001];
	long long n,result;

	void input()
	{
		cin>>n;
		cin>>c;
	}

	void number()
	{
		result=oss(num_max_char(),n);
	}

	int num_max_char()
	{
		int A[4]={0,0,0,0};
		for(int i=0;i<strlen(c);i++)
		{
			if(c[i]=='A') A[0]++;
			else if(c[i]=='C') A[1]++;
			else if(c[i]=='G') A[2]++;
			else if(c[i]=='T') A[3]++;
		}

		int maxx=0,count=0;
		for(int i=0;i<4;i++) if(A[i]>maxx) maxx=A[i];
		for(int i=0;i<4;i++) if(A[i]==maxx) count++;
		return count;
	}

	long long oss(int x,int y)
	{
		long long ans=1;
		for(int i=1;i<=y;i++) {ans*=x; ans%=1000000007;}
		return ans;
	}

	void output()
	{
		cout<<result<<endl;
	}
};

int main()
{
	problem test;
	test.idea();

	//system("pause");
	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
using namespace std;

class problem
{
public:
	void idea()
	{
		input();
		number();
		output();
	}

private:
	char c[5001];
	int n,result;

	void input()
	{
		cin>>n;
		cin>>c;
	}

	void number()
	{
		result=oss(num_char(),n);
		one();
	}

	int num_char()
	{
		string s;
		for(int i=0;i<strlen(c);i++)
		{
			int exist=0;
			for(int j=0;j<s.length();j++) if(c[i]==s.at(j)) exist=1;
			if(exist==0) s+=c[i];
		}
		return s.length();
	}

	int oss(int x,int y)
	{
		int ans=1;
		for(int i=1;i<=y;i++) {ans*=x; ans%=1000000007;}
		return ans;
	}

	void one()
	{
		int A=0,C=0,G=0,T=0;
		for(int i=0;i<strlen(c);i++)
		{
			if(c[i]=='A') A++;
			else if(c[i]=='C') C++;
			else if(c[i]=='G') G++;
			else if(c[i]=='T') T++;
		}

		if(!(A==G && A==C && A==T)) result=1;
	}

	void output()
	{
		cout<<result<<endl;
	}
};

int main()
{
	problem test;
	test.idea();

	//system("pause");
	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
using namespace std;

class problem
{
public:
	void idea()
	{
		input();
		number();
		output();
	}

private:
	char c[5001];
	int n,result;

	void input()
	{
		cin>>n;
		cin>>c;
	}

	void number()
	{
		result=oss(num_char(),n);
	}

	int num_char()
	{
		string s;
		for(int i=0;i<strlen(c);i++)
		{
			int exist=0;
			for(int j=0;j<s.length();j++) if(c[i]==s.at(j)) exist=1;
			if(exist==0) s+=c[i];
		}
		return s.length();
	}

	int oss(int x,int y)
	{
		int ans=1;
		for(int i=1;i<=y;i++) {ans*=x; ans%=1000000007;}
		return ans;
	}

	void output()
	{
		cout<<result<<endl;
	}
};

int main()
{
	problem test;
	test.idea();

	//system("pause");
	return 0;
}