#include <bits/stdc++.h>
using namespace std;
int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);
int lcm(int x, int y);
int main() {
  int N, Q;
  char s[200000];
  cin >> N >> Q >> s;
  char t[200000], d[200000];
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  int l = 0, r = N - 1;
  for (int i = Q - 1; i >= 0; i--) {
    if (t[i] == s[l] && d[i] == 'L')
      l++;
    else if (t[i] == s[r] && d[i] == 'R')
      r--;
    if (t[i] == s[l - 1] && d[i] == 'R') l--;
    if (t[i] == s[r + 1] && d[i] == 'L') r++;
    if (l > r) break;
  }
  cout << r - l + 1;
  return 0;
}
int max(int x, int y) {
  int max;
  if (x < y)
    max = y;
  else
    max = x;
  return max;
}
int min(int x, int y) {
  int min;
  if (x < y)
    min = x;
  else
    min = y;
  return min;
}
int gcd(int x, int y) {
  int m;
  int gcd = 1;
  m = min(x, y);
  for (int i = 1; i <= m; i++) {
    if (x % i == 0 && y % i == 0) gcd = i;
  }
  return gcd;
}
int lcm(int x, int y) {
  int m;
  for (int i = 1; i <= y; i++) {
    if ((x * i) % y == 0) {
      m = x * i;
      break;
    }
  }
  return m;
}
