#include <bits/stdc++.h>
using namespace std;
long long npower(long long a, long long b, long long mod) {
  if (b < 0) return pow(a, b);
  long long ret = 1, placer = a;
  while (b) {
    if (b & 1) ret = (ret * placer) % mod;
    b = (b >> 1);
    placer = (placer * placer) % mod;
  }
  return ret;
}
int main() {
  long long n;
  cin >> n;
  string str;
  cin >> str;
  map<char, long long> ok;
  for (__typeof(n) i = 0; i < n; i++) ok[str[i]]++;
  vector<long long> a;
  for (__typeof(ok.begin()) it = ok.begin(); it != ok.end(); ++it) {
    a.push_back(it->second);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  long long mx = a[0];
  long long ct = 0;
  long long sz = a.size();
  for (__typeof(sz) i = 0; i < sz; i++)
    if (a[i] == mx) ct++;
  long long ans = npower(ct, n, 1000000007);
  cout << ans << endl;
}
