#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  string t[Q], d[Q];
  long long i;
  for (i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  long long l = 0, r = N - 1;
  long long tmp, j;
  bool death;
  long long ans = N;
  while (r - l > 1) {
    tmp = (r + l) / 2;
    j = tmp;
    death = false;
    for (i = 0; i < Q; i++) {
      if (j >= 0 && j <= N - 1 && s[j] == t[i][0]) {
        if (d[i][0] == 'L')
          j--;
        else
          j++;
      }
      if (j < 0) death = true;
    }
    if (death)
      l = tmp;
    else
      r = tmp;
  }
  if (l != 0) {
    ans -= l + 1;
  } else {
    j = 0;
    death = false;
    for (i = 0; i < Q; i++) {
      if (j >= 0 && j <= N - 1 && s[j] == t[i][0]) {
        if (d[i][0] == 'L')
          j--;
        else
          j++;
      }
      if (j < 0) death = true;
    }
    if (death) ans--;
  }
  l = 0;
  r = N - 1;
  while (r - l > 1) {
    tmp = (r + l) / 2;
    j = tmp;
    death = false;
    for (i = 0; i < Q; i++) {
      if (j >= 0 && j <= N - 1 && s[j] == t[i][0]) {
        if (d[i][0] == 'L')
          j--;
        else
          j++;
      }
      if (j > N - 1) death = true;
    }
    if (death)
      r = tmp;
    else
      l = tmp;
  }
  if (r != N - 1) {
    ans -= N - r;
  } else {
    j = N - 1;
    death = false;
    for (i = 0; i < Q; i++) {
      if (j >= 0 && j <= N - 1 && s[j] == t[i][0]) {
        if (d[i][0] == 'L')
          j--;
        else
          j++;
      }
      if (j > N - 1) death = true;
    }
    if (death) ans--;
  }
  cout << ans;
  return 0;
}
