#include <bits/stdc++.h>
using namespace std;
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
long long MOD = 1e9 + 7;
vector<pair<int, int>> G[110000];
int main() {
  int n = in(), q = in();
  string s;
  cin >> s;
  char pre = '!';
  vector<pair<char, char>> p;
  for (long long i = 0; i < q; i++) {
    char s1, s2;
    cin >> s1 >> s2;
    p.push_back({s1, s2});
  }
  int now = 0, m = 0;
  for (long long i = q - 1; i >= 0; i--) {
    if (s[now] == p[i].first && p[i].second == 'L') {
      now++;
      m = max(m, now);
    }
    if (now >= 1 && s[now - 1] == p[i].first && p[i].second == 'R') {
      now = 0;
    }
    if (now >= n) break;
  }
  int now2 = 0, m2 = 0;
  for (long long i = q - 1; i >= 0; i--) {
    if (s[n - 1 - now2] == p[i].first && p[i].second == 'R') {
      now2++;
      m2 = max(m2, now2);
    }
    if (now >= 1 && s[n - now] == p[i].first && p[i].second == 'L') {
      now2 = 0;
    }
    if (now2 >= n) break;
  }
  if (m2 + m >= n) {
    cout << 0;
    return 0;
  } else {
    cout << n - m2 - m;
  }
}
