#include <bits/stdc++.h>
using namespace std;
const long long int INF = 99999999999999999;
long long int a, b, c, d, e, f, ans = 0;
long long int n, q;
string s;
char t[300000], w;
vector<long long int> v;
long long int hantei(long long int x) {
  for (long long int i = 0; i < long long int(q); i++) {
    if (s[x] == t[i]) x += v[i];
    if (x < 0) return -1;
    if (x > n - 1) return 1;
  }
  return 0;
}
int main() {
  cin >> n >> q;
  cin >> s;
  for (long long int i = 0; i < long long int(q); i++) {
    cin >> t[i] >> w;
    if (w == 'L')
      v.push_back(-1);
    else
      v.push_back(1);
  }
  long long int l_min = -1, l_max = n, r_min = 0, r_max = n, l, r;
  while (l_max - l_min > 1) {
    long long int mid = (l_max + l_min) / 2;
    if (hantei(mid) == -1) {
      l_min = mid;
    } else
      l_max = mid;
  }
  l = l_max;
  while (r_max - r_min > 1) {
    long long int mid = (r_max + r_min) / 2;
    if (hantei(mid) == 1) {
      r_max = mid;
    } else
      r_min = mid;
  }
  r = r_max;
  cout << r - l << endl;
}
