#include <bits/stdc++.h>
using namespace std;
void YES(bool flag) { cout << (flag ? "YES" : "NO") << endl; }
void Yes(bool flag) { cout << (flag ? "Yes" : "No") << endl; }
void yes(bool flag) { cout << (flag ? "yes" : "no") << endl; }
const int INF = 1e7;
const long long MOD = 1e9 + 7;
vector<char> t, d;
int main() {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) {
    char tt, td;
    cin >> tt >> td;
    t.push_back(tt);
    d.push_back(td);
  }
  int l = 0, r = n, mid, lp, rp;
  while (l != r - 1) {
    mid = (l + r) / 2;
    lp = mid;
    for (int i = 0; i < q; i++) {
      if (t[i] == s[lp]) {
        if (d[i] == 'L') {
          lp--;
        } else {
          lp++;
        }
      }
      if (lp == -1 || lp == n) {
        break;
      }
    }
    if (lp == -1) {
      l = mid;
    } else {
      r = mid;
    }
  }
  lp = mid;
  l = 0, r = n;
  while (l != r - 1) {
    mid = (l + r) / 2;
    rp = mid;
    for (int i = 0; i < q; i++) {
      if (t[i] == s[rp]) {
        if (d[i] == 'L') {
          rp--;
        } else {
          rp++;
        }
      }
      if (rp == -1 || rp == n) {
        break;
      }
    }
    if (rp == n) {
      r = mid;
    } else {
      l = mid;
    }
  }
  rp = mid;
  cout << rp - lp + 1 << endl;
  return 0;
}
