import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum MO = 10L^^9 + 7;

long calc(int N, int L) {
  debug {
    writeln("calc ", N, " ", L);
  }
  long ret;
  auto dp = new long[N + 1];
  auto dpSum = new long[N + 2];
  dp[0] = 1;
  dpSum[1] = 1;
  foreach (x; 1 .. N + 1) {
    dp[x] = (dpSum[x] - dpSum[max(x - L, 0)]) % MO;
    dpSum[x + 1] = (dpSum[x] + dp[x]) % MO;
  }
  foreach (y; 1 .. L + 1) {
    ret += dp[N - y] * y;
    ret %= MO;
  }
  debug {
    writeln("dp = ", dp);
    writeln("ret = ", ret);
  }
  ret *= 2;
  ret %= MO;
  return ret;
}

void main() {
  /*
  foreach (k; 1 .. 10 + 1) {
    write(k);
    foreach (l; 1 .. 10 + 1) {
      bool ok = true;
      foreach (a; 0 .. l + 1) {
        ok = ok && ((a <= k && (k - a) % 2 == 0) || (l - a <= k && (k - (l - a)) % 2 == 0));
      }
      if (ok) {
        write(" ", l);
      }
    }
    writeln();
  }
  */
  
  try {
    for (; ; ) {
      const N = readInt();
      const M = readInt();
      const S = readToken();
      
      debug {
        int ansBrute;
        foreach (p; 0 .. 1 << N) {
          bool ok = true;
          foreach (s; 0 .. N) {
            auto dp = new bool[][](M + 1, N);
            dp[0][s] = true;
            foreach (i; 0 .. M) {
              foreach (u; 0 .. N) {
                if (dp[i][u]) {
                  if (S[i] == "RB"[(p >> u) & 1]) {
                    dp[i + 1][(u + 1) % N] = true;
                  }
                  if (S[i] == "RB"[(p >> ((u - 1 + N) % N)) & 1]) {
                    dp[i + 1][(u - 1 + N) % N] = true;
                  }
                }
              }
            }
            ok = ok && dp[M].any;
          }
          if (ok) {
            ++ansBrute;
            /*
            auto a = iota(N).map!(u => (p >> u) & 1);
            write(a);
            foreach (u; 0 .. N) {
              if ((p >> u) & 1) {
                for (int v = u, w = u; v < u + N; v = w) {
                  for (; w < u + N && a[v % N] == a[w % N]; ++w) {}
                  if (a[v % N] == 0) {
                    write(" ", w - v);
                  }
                }
                writeln();
                break;
              }
            }
            */
          }
        }
        writeln("ansBrute = ", ansBrute);
      }
      
      auto A = new int[M];
      foreach (i; 0 .. M) {
        A[i] = (S[i] == 'R') ? 0 : 1;
      }
      if (A[0] == 1) {
        foreach (i; 0 .. M) {
          A[i] ^= 1;
        }
      }
      debug {
        writeln("A = ", A);
      }
      int lim = N - 1;
      if (lim % 2 == 0) {
        --lim;
      }
      for (int i = 0, j = 0; i < M; i = j) {
        for (; j < M && A[i] == A[j]; ++j) {}
        if (A[i] == 0) {
          debug {
            writeln("segment ", i, " ", j);
          }
          if (i == 0) {
            if (j == M) {
              // ok
            } else {
              chmin(lim, 2 * ((j - i) / 2) + 1);
            }
          } else {
            if (j == M) {
              // ok
            } else {
              if ((j - i) % 2 != 0) {
                chmin(lim, j - i);
              }
            }
          }
        }
      }
      debug {
        writeln("lim = ", lim);
      }
      
      long ans;
      if (A.all!"a == 0") {
        // just no 11
        foreach (s; 0 .. 2) {
          auto dp = new long[][](N, 2);
          dp[0][s] = 1;
          foreach (i; 1 .. N) {
            dp[i][0] += dp[i - 1][0];
            dp[i][1] += dp[i - 1][0];
            dp[i][0] += dp[i - 1][1];
            dp[i][] %= MO;
          }
          foreach (t; 0 .. 2) {
            if (!(s == 1 && t == 1)) {
              ans += dp[N - 1][t];
              ans %= MO;
            }
          }
        }
      } else {
        if (N % 2 == 0) {
          ans += calc(N / 2, (lim + 1) / 2);
        }
      }
      ans = (ans % MO + MO) % MO;
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}
