#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1E9 + 7;
int pow_mod(int x, int n) {
  if (n == 1) {
    return x;
  }
  long long base = x, res = 1;
  while (n) {
    if (n & 1) {
      res *= base;
      if (res >= MOD) {
        res %= MOD;
      }
    }
    n >>= 1;
    base *= base;
    if (base >= MOD) {
      base %= MOD;
    }
  }
  return res;
}
int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> count(26, 0);
  int maxc = 0;
  for (int i = 0; i < n; ++i) {
    ++count[s[i] - 'A'];
    maxc = max(maxc, count[s[i] - 'A']);
  }
  int m = 0;
  for (int i = 0; i < 26; ++i) {
    if (maxc == count[i]) {
      ++m;
    }
  }
  if (m == 1) {
    cout << 1 << endl;
  } else {
    cout << pow_mod(m, n) << endl;
  }
  return 0;
}
