#include <bits/stdc++.h>
using namespace std;
long long n, q;
string s;
char t[300000], d[300000];
int check(int index) {
  char now_a;
  int now_n;
  if (index == 0)
    return 0;
  else if (index == n + 1)
    return n + 1;
  now_a = s[index - 1];
  now_n = index;
  for (int i = 0; i < q; i++) {
    if (now_a == t[i]) {
      if (d[i] == 'L') {
        now_n--;
      } else {
        now_n++;
      }
      if (now_n == 0) {
        return 1;
      } else if (now_n == n + 1) {
        return 2;
      }
      now_a = s[now_n - 1];
    }
  }
  return 0;
}
int binary_serch(int value) {
  int lower, upper, mid, hoge;
  lower = 1;
  upper = n;
  if (value == 1) {
    while (lower < upper) {
      mid = (lower + upper) / 2;
      hoge = check(mid);
      if (hoge == 1) {
        lower = mid + 1;
      } else {
        upper = mid - 1;
      }
    }
    if (lower == 0) return 0;
    if (check(lower - 1) == 1 && check(lower) == 0)
      return lower - 1;
    else if (check(lower) == 1 && check(lower + 1) == 0)
      return lower;
  } else {
    while (lower < upper) {
      mid = (lower + upper) / 2;
      hoge = check(mid);
      if (hoge == 2) {
        upper = mid - 1;
      } else {
        lower = mid + 1;
      }
    }
    if (upper == n + 1) return n + 1;
    if (check(upper + 1) == 2 && check(upper) == 0)
      return upper + 1;
    else if (check(upper) == 2 && check(upper - 1) == 0)
      return upper;
  }
}
int main() {
  int min, max, ans = 0;
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  min = binary_serch(1);
  max = binary_serch(2);
  ans = min + (n + 1) - max;
  cout << n - ans << endl;
  return 0;
}
