#include <bits/stdc++.h>
using namespace std;
int main() {
  int res;
  int N, Q;
  cin >> N >> Q;
  res = N;
  string s;
  cin >> s;
  char t[1000000], d[1000000];
  for (int i = 1; i <= Q; i++) cin >> t[i] >> d[i];
  for (int i = 1; i <= N; i++) {
    int nowp = i;
    for (int j = 1; j <= Q; j++) {
      if (t[j] == s[nowp - 1]) {
        nowp = (d[j] == 'L') ? nowp - 1 : nowp + 1;
      }
      if (nowp == 0 || nowp == N + 1) {
        res--;
        break;
      }
    }
  }
  cout << res << endl;
}
