#include <bits/stdc++.h>
using namespace std;
deque<int> dq[100];
char s[200010], s1[200010][11], s2[200010][11];
int n, q;
bool chck1(int x) {
  if (x == 0) return 1;
  x = n - x;
  for (int i = 0; i < q; ++i) {
    if (s2[i][0] == 'R') {
      if (s1[i][0] == s[x]) {
        ++x;
      }
    } else {
      if (x > 0)
        if (s1[i][0] == s[x]) {
          --x;
        }
    }
    if (x == n) return 1;
  }
  return 0;
}
bool chck2(int x) {
  if (x == 0) return 1;
  --x;
  for (int i = 0; i < q; ++i) {
    if (s2[i][0] == 'L') {
      if (s1[i][0] == s[x]) {
        --x;
      }
    } else {
      if (x > 0)
        if (s1[i][0] == s[x]) {
          ++x;
        }
    }
    if (x == -1) return 1;
  }
  return 0;
}
int main() {
  while (cin >> n >> q) {
    scanf("%s", s);
    int ans = n;
    for (int i = 0; i < q; ++i) {
      scanf("%s%s", s1[i], s2[i]);
    }
    int st = 0, nd = n, md;
    while (st < nd) {
      md = (st + nd + 1) / 2;
      if (chck1(md)) {
        st = md;
      } else {
        nd = md - 1;
      }
    }
    ans -= st;
    st = 0, nd = n;
    while (st < nd) {
      md = (st + nd + 1) / 2;
      if (chck2(md)) {
        st = md;
      } else {
        nd = md - 1;
      }
    }
    ans -= st;
    ans = max(0, ans);
    cout << ans << endl;
  }
  return 0;
}
