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