#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  int golem[N];
  int mass[N];
  int ans = 0;
  for (int i = 0; i < N; i++) golem[i] = 1;
  array<vector<int>, 26> al;
  map<char, int> mp;
  mp['L'] = -1;
  mp['R'] = 1;
  for (int i = 0; i < N; i++) {
    al[s[i] - 'A'].push_back(i);
  }
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    int tmp = mp[d];
    for (auto itr = al[t - 'A'].begin(); itr != al[t - 'A'].end(); ++itr) {
      if ((*itr == 0 and tmp == -1) or (*itr == N - 1 and tmp == 1)) {
        ans += golem[*itr];
        golem[*itr] = 0;
      } else {
        golem[*itr + tmp] += golem[*itr];
        golem[*itr] = 0;
      }
    }
  }
  cout << N - ans << endl;
  return 0;
}
