#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x * y / gcd(x, y); }
long long kai(long long x) {
  if (x == 0) return 1;
  return kai(x - 1) * x;
}
long long mod_pow(long long x, long long y, long long mod) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    y >>= 1;
  }
  return res;
}
long long comb(long long x, long long y) {
  return kai(x) *
         mod_pow(kai(x - y), (long long)(1e9 + 7) - 2, (long long)(1e9 + 7)) %
         (long long)(1e9 + 7) *
         mod_pow(kai(y), (long long)(1e9 + 7) - 2, (long long)(1e9 + 7)) %
         (long long)(1e9 + 7);
}
long long n, m;
string s;
pair<char, char> p[214514];
long long ans;
signed main() {
  cin >> n >> m >> s;
  for (long long i = 0; i < m; i++) {
    cin >> p[i].first >> p[i].second;
  }
  long long memo = 0;
  for (long long i = m - 1; i >= 0; i--) {
    if (s[memo] == p[i].first && p[i].second == 'L') {
      ans++;
      memo++;
    } else if (s[memo] == p[i].first) {
    }
  }
  memo = n - 1;
  for (long long i = m - 1; i >= 0; i--) {
    if (s[memo] == p[i].first && p[i].second == 'R') {
      ans++;
      memo--;
    } else if (s[memo] == p[i].first) {
    }
  }
  cout << n - ans << endl;
}
