#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
const long long MOD = 1e9 + 7;
long long n, q;
string s;
vector<char> t(100010), d(100010);
long long check(long long x) {
  for (int i = 0; i < q; i++) {
    if (t[i] != s[x]) continue;
    if (d[i] == 'L')
      --x;
    else
      ++x;
    if (x == -1 || x == n) return x;
  }
  return 0;
}
int main() {
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  t.resize(q);
  d.resize(q);
  long long sum = 0;
  long long lb = -1, ub = n;
  while (ub - lb > 1) {
    long long mid = (ub + lb) / 2;
    if (check(mid) == -1)
      lb = mid;
    else
      ub = mid;
  }
  sum += ub;
  lb = -1, ub = n;
  while (ub - lb > 1) {
    long long mid = (ub + lb) / 2;
    if (check(mid) == n)
      ub = mid;
    else
      lb = mid;
  }
  sum += n - ub;
  cout << n - sum << endl;
  return 0;
}
