#include <bits/stdc++.h>
using namespace std;
char t[300000], d[300000];
long long N, Q;
string s;
bool mycheck(long long goal, long long place) {
  for (long long i = 1; i <= Q; i++) {
    if (t[i] == s[place - 1]) {
      if (d[i] == 'L')
        place--;
      else
        place++;
    }
    if (place == goal) return true;
  }
  return false;
}
int main() {
  cin >> N >> Q >> s;
  for (long long i = 1; i <= Q; i++) {
    cin >> t[i] >> d[i];
  }
  long long s = 0, e = N, ans0, ansN, ans, h;
  h = (s + e) / 2;
  while (true) {
    if (mycheck(0, h))
      s = h;
    else
      e = h;
    h = (s + e) / 2;
    if (s + 1 == e) break;
  }
  ans0 = s;
  s = 1, e = N + 1;
  h = (s + e) / 2;
  while (true) {
    if (mycheck(N + 1, h))
      e = h;
    else
      s = h;
    h = (s + e) / 2;
    if (s + 1 == e) break;
  }
  ansN = e;
  if (ans0 >= ansN)
    ans = N;
  else
    ans = ans0 + (N + 1 - ansN);
  cout << N << endl;
}
