#include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
char t[200000], d[200000];
bool exit_from(int nn, char direction) {
  int a = nn;
  for (int i = 0; i < q; i++) {
    if (t[i] != s[a]) {
      continue;
    }
    if (d[i] == 'L') {
      a--;
    } else {
      a++;
    }
    if (a < 0) {
      return true;
    }
    if (a > n - 1) {
      return true;
    }
  }
  return false;
}
int main() {
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  int a = 0;
  int b = n - 1;
  int left = -1;
  while (1) {
    int search = a + ((b - a) / 2);
    if (exit_from(search, 'L')) {
      left = search;
      a = search + 1;
    } else {
      b = search - 1;
    }
    if (b < a) {
      break;
    }
  }
  a = 0;
  b = n - 1;
  int right = n;
  while (1) {
    int search = a + ((b - a) / 2);
    if (exit_from(search, 'R')) {
      right = search;
      b = search - 1;
    } else {
      a = search + 1;
    }
    if (b < a) {
      break;
    }
  }
  cout << n - (left + 1) - (n - right) << endl;
  return 0;
}
