#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 15;
const int mod = 1e9 + 7;
int fac[N], inv[N];
int add(int x, int y) { return ((x + y) % mod + mod) % mod; }
int mul(int x, int y) { return (long long)x * y % mod; }
int mypow(int x, int c) {
  int ret = 1;
  while (c > 0) {
    if (c & 1) {
      ret = mul(ret, x);
    }
    c /= 2;
    x = mul(x, x);
  }
  return ret;
}
int gcd(int x, int y) {
  if (x == 0) {
    return y;
  }
  return gcd(y % x, x);
}
int combi(int n, int r) {
  if (n < r) {
    return 0;
  }
  return mul(fac[n], mul(inv[r], inv[n - r]));
}
void init() {
  fac[0] = 1;
  for (int i = 1; i < N; ++i) {
    fac[i] = mul(fac[i - 1], i);
  }
  inv[N - 1] = mypow(fac[N - 1], mod - 2);
  for (int i = N - 2; i; --i) {
    inv[i] = mul(inv[i + 1], i + 1);
    assert(mul(inv[i], fac[i]) == 1);
  }
  inv[0] = 1;
}
char s[N];
int dp[4], tdp[4];
void solve2() {
  int n;
  scanf("%d %s ", &n, s);
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 4; ++j) tdp[j] = 0;
    int st, ed;
    st = s[i] == '?' ? 0 : s[i] - 'a';
    ed = s[i] == '?' ? 2 : s[i] - 'a';
    for (int j = st; j <= ed; ++j) {
      for (int k = 0; k < 4; ++k) {
        if (k == j) tdp[k + 1] = add(tdp[k + 1], dp[k]);
        tdp[k] = add(tdp[k], dp[k]);
      }
    }
    for (int j = 0; j < 4; ++j) dp[j] = tdp[j];
  }
  printf("%d\n", dp[3]);
}
void solve() {
  init();
  solve2();
}
inline bool exists_test0(const std::string& name);
inline bool exists_test1(const std::string& name);
int main() {
  solve();
  return 0;
}
inline bool exists_test0(const std::string& name) {
  ifstream f(name.c_str());
  return f.good();
}
inline bool exists_test1(const std::string& name) {
  if (FILE* file = fopen(name.c_str(), "r")) {
    fclose(file);
    return true;
  } else {
    return false;
  }
}
