15
txxtxttxxttxtxx
 3
myw
 127
xixtxixnxixtxixlxixtxixnxixtxixoxixtxixnxixtxixlxixtxixnxixtxixhxixtxixnxixtxixlxixtxixnxixtxixoxixtxixnxixtxixlxixtxixnxixtxix
 1
a
 10
isssisssss
 2
ff
 1
z

27824
 10
 944124121
 1
 176
 1
 1

#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 5001;
int main() {
  int n;
  cin >> n;
  string str;
  cin >> str;
  string compressedColony = "#" + string(1, str[0]);
  char last = str[0];
  for (int i = 0; i < str.size(); i++) {
    if (last != str[i]) {
      compressedColony += string(1, str[i]);
      last = str[i];
    }
  }
  int m = compressedColony.size();
  int dp[MAXN][MAXN] = {0};
  int cntK[MAXN][MAXN] = {0};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i + 1; j++) {
      if (j >= m) {
        break;
      }
      if (i == j || j == 0) {
        cntK[i][j] = 1;
      } else {
        cntK[i][j] = (cntK[i - 1][j] + cntK[i - 1][j - 1]) % MOD;
      }
    }
  }
  int nextChar[MAXN][26] = {-1};
  for (int i = 0; i < m; i++) {
    for (int j = 'a'; j < 'z' + 1; j++) {
      for (int k = i + 1; k < m; k++) {
        if (compressedColony[k] == j) {
          nextChar[i][j - 'a'] = k;
          break;
        }
      }
    }
  }
  for (int j = 'a'; j < 'z' + 1; j++) {
    if (nextChar[0][j - 'a'] != -1) {
      dp[nextChar[0][j - 'a']][1] = 1;
    }
  }
  for (int i = 1; i < m; i++) {
    for (int j = 1; j < i + 1; j++) {
      for (int symbol = 'a'; symbol <= 'z'; symbol++) {
        if (symbol != compressedColony[i]) {
          int idx = nextChar[i][symbol - 'a'];
          if (idx != -1) {
            dp[idx][j + 1] = (dp[idx][j + 1] + dp[i][j]) % MOD;
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i < m; i++) {
    for (int length = 1; length <= i; length++) {
      if (dp[i][length] > 0) {
        ans = (ans + (dp[i][length] * cntK[n - 1][length - 1]) % MOD) % MOD;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
