#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  map<char, vector<int> > mp;
  vector<int> f(N);
  for (int i = 0; i < N; i++) {
    mp[s[i]].push_back(i);
    f[i] = 1;
  }
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    vector<int> tar = mp[t];
    if (d == 'L') {
      for (int i = 0; i < tar.size(); i++) {
        int x = tar[i];
        if (x != 0) f[x - 1] += f[x];
        f[x] = 0;
      }
    } else {
      for (int i = tar.size() - 1; i >= 0; i--) {
        int x = tar[i];
        if (x != N - 1) f[x + 1] += f[x];
        f[x] = 0;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += f[i];
  }
  cout << ans << endl;
}
