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