#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  if (a == 1 || b == 0) return 1;
  long long c = power(a, b / 2);
  long long res = 1;
  res = c * c;
  if (res >= 1000000007) res %= 1000000007;
  if (b % 2) res *= a;
  if (res >= 1000000007) res %= 1000000007;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  string s;
  cin >> s;
  map<char, long long> count;
  for (long long i = 0; i < n; i++) {
    count[s[i]]++;
  }
  vector<long long> v;
  for (auto &i : count) {
    v.push_back(i.second);
  }
  long long ans = 0;
  sort(v.begin(), v.end(), greater<long long>());
  for (long long i = 0; i < v.size(); i++) {
    if (v[i] == v[0]) ans++;
  }
  cout << power(ans, n);
}
