#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = (ll)1e9 + 7;
bool check(string &s, int Q, int N, int pos, vector<char> &t, vector<char> &d) {
  char c = s[pos];
  for (int i = (int)(0), i_end = (int)(Q); i < i_end; ++i) {
    if (t[i] == c) {
      pos += d[i] == 'L' ? -1 : 1;
      if (pos < 0 || N <= pos) return false;
      c = s[pos];
    }
  }
  return true;
}
int main() {
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  vector<char> t(Q);
  vector<char> d(Q);
  for (int i = (int)(0), i_end = (int)(Q); i < i_end; ++i) {
    cin >> t[i] >> d[i];
  }
  int ans = N;
  {
    int ok = N;
    int ng = -1;
    while (ok - ng > 1) {
      int mid = (ok + ng) / 2;
      (check(s, Q, N, mid, t, d) ? ok : ng) = mid;
    }
    ans -= ng + 1;
  }
  {
    int ok = -1;
    int ng = N;
    while (ng - ok > 1) {
      int mid = (ok + ng) / 2;
      (check(s, Q, N, mid, t, d) ? ok : ng) = mid;
    }
    ans -= N - ng;
  }
  cout << ans << endl;
  return 0;
}
