#include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
char t[200010], d[200010];
int solve(int now) {
  for (int i = 0; i < q; i++) {
    if (s[now] == t[i]) {
      if (d[i] == 'L')
        now--;
      else
        now++;
      if (now == -1)
        return -1;
      else if (now == n)
        return 1;
    }
  }
  return 0;
}
int main() {
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  long long int low = -1, up = n, mid;
  while (up - low > 1) {
    mid = (up + low) / 2;
    if (solve(mid) < 1) {
      low = mid;
    } else {
      up = mid;
    }
  }
  int ans = n, right = up;
  low = 0, up = n - 1;
  while (up - low > 1) {
    mid = (up + low) / 2;
    if (solve(mid) == -1) {
      low = mid;
    } else {
      up = mid;
    }
  }
  int left = low;
  cerr << left << " " << right << endl;
  cout << right - left - 1 << endl;
}
