#include <bits/stdc++.h>
using namespace std;
int n, q, L, R;
string s;
vector<pair<char, char> > qu;
int bs1() {
  int l = 0, r = n;
  while (l + 1 < r) {
    int mid = (l + r) / 2;
    int tmp = mid;
    bool flag = false;
    for (auto i : qu) {
      if (i.first == s[tmp]) {
        if (i.second == 'L')
          tmp--;
        else
          tmp++;
      }
      if (tmp == -1) {
        flag = true;
        break;
      }
      if (tmp == n) break;
    }
    if (flag)
      l = mid;
    else
      r = mid;
  }
  return r;
}
int bs2() {
  int l = -1, r = n - 1;
  while (l + 1 < r) {
    int mid = (l + r) / 2;
    int tmp = mid;
    bool flag = false;
    for (auto i : qu) {
      if (i.first == s[tmp]) {
        if (i.second == 'L')
          tmp--;
        else
          tmp++;
      }
      if (tmp == -1) break;
      if (tmp == n) {
        flag = true;
        break;
      }
    }
    if (flag)
      r = mid;
    else
      l = mid;
  }
  return l;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> q >> s;
  while (q--) {
    char t1, t2;
    cin >> t1 >> t2;
    qu.push_back({t1, t2});
  }
  L = bs1();
  R = bs2();
  cout << R - L + 1 << endl;
  return 0;
}
