#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    string sign;

    cin >> n >> sign;

    int dp[26] = {};

    for (char const& c : sign) {
        if (c == 'A') {
            dp[0]++;
            dp[0] %= 1000000007;
        } else {
            dp[c - 65] += dp[c - 66] % 1000000007;
            dp[c - 65] %= 1000000007;
        }
    }

    cout << dp[25];
}