#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1e9;
long long N, Q;
string s;
vector<char> t, d;
bool checkl(long long X) {
  for (int i = 0; i < int(Q); ++i) {
    if (t[i] == s[X]) {
      if (d[i] == 'R') {
        X++;
      } else {
        X--;
      }
    }
    if (X == -1) {
      return false;
    }
  }
  return true;
}
bool checkr(long long X) {
  for (int i = 0; i < int(Q); ++i) {
    if (t[i] == s[X]) {
      if (d[i] == 'R') {
        X++;
      } else {
        X--;
      }
      if (X == N) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  cin >> N >> Q >> s;
  t.resize(Q);
  d.resize(Q);
  for (int i = 0; i < int(Q); ++i) {
    cin >> t[i] >> d[i];
  }
  long long ng = 0;
  long long ok = N + 1;
  while (ok - ng > 1) {
    long long mid = (ok + ng) / 2;
    if (checkl(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  long long l = ok;
  ok = 0;
  ng = N + 1;
  while (ng - ok > 1) {
    long long mid = (ok + ng) / 2;
    if (checkr(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  long long r = ok;
  cerr << l << " " << r << endl;
  cout << r - l + 1 << endl;
}
