#include using namespace std; #include using namespace atcoder; using ll = long long; using vi = vector; using vvi = vector>; using pii = pair; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define repr(i, n) for (int i = (int)(n - 1); i >= 0; --i) using mint = modint1000000007; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; string s; cin >> n >> s; mint ret = 0; char t = 'A'; repr(i, n) { if (s[i] != t) { char c = 'A'; ret += mint(2).pow(i); while (c == s[i] || c == t) c++; t = c; } } cout << ret.val() << endl; return 0; }