#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, cnt[200001], ans;
  string s;
  char t, d;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cnt[i] = 1;
  }
  cin >> s;
  ans = n;
  for (int i = 0; i < q; i++) {
    cin >> t >> d;
    for (int j = 0; j < n; j++) {
      if (s[j] == t) {
        if (d == 'L') {
          if (j == 0) {
            ans -= cnt[j];
            cnt[j] -= cnt[j];
          } else {
            cnt[j - 1] += cnt[j];
            cnt[j] -= cnt[j];
          }
        } else {
          if (j == n - 1) {
            ans -= cnt[j];
            cnt[j] -= cnt[j];
          } else {
            cnt[j + 1] += cnt[j];
            cnt[j] -= cnt[j];
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
