#include <bits/stdc++.h>
using namespace std;
long long mo = 1000000007, ans = 0;
long long dp[0][0];
int main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  s = 'z' + s + 'z';
  char t[q];
  char d[q];
  for (long long i = 0; i < (long long)(q); i++) {
    cin >> t[i] >> d[i];
  }
  char now;
  int ichi, syo, sita = 0, ue = 0;
  int x = 0, z = n + 1;
  while (true) {
    syo = (x + z) / 2;
    ichi = syo;
    now = s[ichi];
    for (long long i = 0; i < (long long)(q); i++) {
      if (now == t[i]) {
        if (d[i] == 'L') {
          now = s[ichi - 1];
          ichi--;
        } else {
          now = s[ichi + 1];
          ichi++;
        }
      }
    }
    if (ichi == 0) {
      x = syo + 1;
      if (x == z) {
        sita = syo;
        break;
      }
    } else {
      z = syo;
      if (x == z - 1) {
        sita = syo - 1;
        break;
      }
    }
  }
  x = 0;
  z = n + 1;
  while (true) {
    syo = (x + z) / 2;
    ichi = syo;
    now = s[ichi];
    for (long long i = 0; i < (long long)(q); i++) {
      if (now == t[i]) {
        if (d[i] == 'L') {
          now = s[ichi - 1];
          ichi--;
        } else {
          now = s[ichi + 1];
          ichi++;
        }
      }
    }
    if (ichi != n + 1) {
      x = syo + 1;
      if (x == z) {
        ue = syo + 1;
        break;
      }
    } else {
      z = syo;
      if (x == z - 1) {
        ue = syo;
        break;
      }
    }
  }
  ans = -sita + ue - 1;
  cout << ans << endl;
  return 0;
}
