#include <iostream>
#include <unordered_map>
#define MOD 1000000007
using namespace std;

char x[1000005];
char src[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
long long mul[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
unordered_map<char, int> cnt;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(); cout.tie();
	int n;
	cin >> n;
	cin >> x;
	for (int i = 0; i < n; i++) cnt[x[i]]++;
	int index = 0;
	int starter = 0;
	while (x[starter] != 'A') starter++;
	char curr = 'A';
	char next = 'B';
	int num = 2;
	int i = starter + 1;
	while (i < n)
	{
		if (x[i] != curr && x[i] == next)
		{
			curr = next;
			next = src[num++];
		}
		else if (x[i] == curr)
		{
			mul[num - 1]++;
		}
		i++;
	}
	long long res = 1;

	for (i = 0; i < 27; i++)
	{
		res *= mul[i];
		res %= MOD;
	}
	cout << res << endl;

}