#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int cnt[26] = {};
int ans = 0;
const int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> s;
  for (int i = 0; i < (int)(n); ++i) ++cnt[s[i] - 'A'];
  int mx = cnt[0];
  for (int i = 0; i < (int)(26); ++i) mx = max(mx, cnt[i]);
  for (int i = 0; i < (int)(26); ++i)
    if (cnt[i] == mx) ++ans;
  int mul = ans;
  for (int i = 1; i < n; ++i) ans = ((long long)ans * mul) % MOD;
  cout << ans << endl;
  return 0;
}
