#include <bits/stdc++.h>
using namespace std;
const int L = 2e5 + 10;
char ts[L];
char ds[L];
char s[L];
int main() {
  int N, Q;
  cin >> N >> Q >> (s + 1);
  for (int i = 0; i < Q; i++) {
    cin >> ts[i] >> ds[i];
  }
  int low = 0;
  int hi = N;
  while (low + 1 < hi) {
    int m = (low + hi) / 2;
    int p = m;
    for (int i = 0; i < Q; i++) {
      if (ts[i] == s[p]) {
        if (ds[i] == 'L') {
          p--;
        } else {
          p++;
        }
      }
    }
    if (p == 0) {
      low = m;
    } else {
      hi = m;
    }
  }
  int ret = low;
  low = 1;
  hi = N + 1;
  while (low + 1 < hi) {
    int m = (low + hi) / 2;
    int p = m;
    for (int i = 0; i < Q; i++) {
      if (ts[i] == s[p]) {
        if (ds[i] == 'L') {
          p--;
        } else {
          p++;
        }
      }
    }
    if (p == N + 1) {
      hi = m;
    } else {
      low = m;
    }
  }
  ret += N + 1 - hi;
  cout << N - ret << endl;
  return 0;
}
