#include <bits/stdc++.h>
using namespace std;
long long mod(long long a) {
  long long c = a % (long long)(1E9 + 7);
  if (c >= 0) return c;
  return c + (long long)(1E9 + 7);
}
long long inf = (long long)1E17;
long long max(long long a, long long b) {
  if (a < b)
    return b;
  else
    return a;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
void Max(long long &pos, long long val) { pos = max(pos, val); }
void Min(long long &pos, long long val) { pos = min(pos, val); }
void Add(long long &pos, long long val) { pos = mod(pos + val); }
long double EPS = 1E-9;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  string t[q][2];
  for (long long i = 0; i <= q - 1; i++)
    for (long long j = 0; j <= 1; j++) cin >> t[i][j];
  long long pl = 0, pr = n - 1;
  for (long long i = q - 1; i >= 0; i--) {
    if (t[i][1][0] == 'L') {
      if (s[pl] == t[i][0][0]) {
        pl++;
      }
    } else {
      if (s[pr] == t[i][0][0]) {
        pr--;
      }
    }
    if (pl > pr) break;
  }
  if (pl > pr)
    cout << 0 << endl;
  else {
    cout << pr - pl + 1 << endl;
  }
  return 0;
}
