#include <bits/stdc++.h>
constexpr int kMod = 1000000007;
int main() {
  int N, Q;
  std::cin >> N >> Q;
  std::string S;
  std::cin >> S;
  std::string ts, ds;
  int lcnt = 0, rcnt = 0;
  for (int i = 0; i < Q; ++i) {
    char a, b;
    std::cin >> a >> b;
    ts += a;
    ds += b;
    if (b == 'L') ++lcnt;
    if (b == 'R') ++rcnt;
  }
  int cnt = N;
  for (int i = 1; i <= N; ++i) {
    char c = S[i - 1];
    int remain_l = lcnt;
    int remain_r = rcnt;
    int pos = i;
    for (int j = 0; j < Q; ++j) {
      if (c == ts[j]) {
        if (ds[j] == 'L') {
          --pos;
        } else {
          ++pos;
        }
        c = S[pos - 1];
        if (pos == 0 || pos == N + 1) {
          --cnt;
          break;
        }
      }
      if (pos > lcnt && N - pos > rcnt) break;
    }
  }
  std::cout << cnt << std::endl;
}
