#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;
set<long long> st[30];
char c[214514];
signed main() {
  cin >> n >> m >> s;
  for (long long i = 0; i < m; i++) {
    char a, b;
    cin >> a >> b;
    st[a - 'A'].insert(i);
    c[i] = b;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long no = 0, whe = i;
    while (1) {
      long long al = s[whe] - 'A';
      if (st[al].lower_bound(no) == st[al].end()) break;
      long long k = *st[al].lower_bound(no);
      if (c[k] == 'L')
        whe--;
      else
        whe++;
      if (whe == -1 || whe == n) {
        ans++;
        break;
      }
      no = k + 1;
    }
  }
  cout << n - ans << endl;
}
