#include <bits/stdc++.h>
using namespace std;
const int N = 5005, mod = 1e9 + 7;
string str;
vector<int> nxt[N];
int dp[N][N], n, m;
int f(int i, int k) {
  if (!k) return 1;
  if (i == str.size()) return 0;
  if (~dp[i][k]) return dp[i][k];
  int r = (f(i, k - 1) + f(i + 1, k)) % mod;
  if (i + 1 < m && nxt[i + 1][str[i] - 'a'] < m) {
    r += mod - f(nxt[i + 1][str[i] - 'a'], k - 1);
    r %= mod;
  }
  return dp[i][k] = r % mod;
}
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> n >> s;
  for (auto ch : s)
    if (str.empty() || str.back() != ch) {
      str.push_back(ch);
    }
  m = str.size();
  vector<int> tmp(26, m);
  for (int i = m - 1; i >= 0; i--) {
    tmp[str[i] - 'a'] = i;
    nxt[i] = tmp;
  }
  memset(dp, -1, sizeof dp);
  cout << f(0, n) << endl;
}
