#include <bits/stdc++.h>
using namespace std;
bool CL(int x, int Q, int N, string S, vector<char> t, vector<char> d) {
  for (int i = 0; i < Q; i++) {
    if (S[x - 1] == t[i]) {
      if (d[i] - 'L' == 0) {
        x = x - 1;
      } else {
        x++;
      }
    }
    if (x < 1) {
      return false;
    }
    if (x > N) {
      return true;
    }
  }
  return true;
}
bool CR(int x, int Q, int N, string S, vector<char> t, vector<char> d) {
  for (int i = 0; i < Q; i++) {
    if (S[x - 1] == t[i]) {
      if (d[i] - 'L' == 0) {
        x--;
      } else {
        x++;
      }
    }
    if (x < 1) {
      return true;
    }
    if (x > N) {
      return false;
    }
  }
  return true;
}
int main() {
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<char> t(Q);
  vector<char> d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  int lbL = 0, ubL = N;
  while (ubL - lbL > 1) {
    int mid = (lbL + ubL) / 2;
    if (CL(mid, Q, N, S, t, d)) {
      ubL = mid;
    } else {
      lbL = mid;
    }
  }
  int lbR = 0, ubR = N;
  while (ubR - lbR > 1) {
    int mid = (lbR + ubR) / 2;
    if (CR(mid, Q, N, S, t, d)) {
      lbR = mid;
    } else {
      ubR = mid;
    }
  }
  if (ubR == N) {
    lbR = N;
  }
  int ans;
  ans = lbR - ubL + 1;
  if (ans > 0) {
    cout << ans;
  } else {
    cout << 0;
  }
  return 0;
}
