#include <bits/stdc++.h>
using namespace std;
long long n, k;
char p[1000000], q[1000000];
string s;
bool zere = false;
int main() {
  cin >> n >> k >> s;
  long long L = 0, R = n;
  for (int i = 1; i <= k; i++) {
    cin >> p[i] >> q[i];
  }
  for (int i = 1; i <= k; i++) {
    if (q[i] == 'L') {
      if (L < n and s[L] == p[i]) L++;
      if (R < n and s[R] == p[i]) R++;
    } else {
      if (L > 0 and s[L - 1] == p[i]) --L;
      if (R > 0 and s[R - 1] == p[i]) --R;
    }
  }
  cout << max(0LL, R - L - 1);
}
