#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q, dir, aft;
  string c;
  cin >> N >> Q >> c;
  vector<int> G(N, 1);
  vector<char> C(N);
  for (int i = 0; i < N; i++) C[i] = c[i];
  char t, d;
  for (int i = 0; i < Q; i++) {
    cin >> t >> d;
    if (d == 'L')
      dir = -1;
    else
      dir = 1;
    for (int j = 0; j < N; j++) {
      if (C[j] == t) {
        aft = j + dir;
        if (aft < 0 || aft >= N)
          G[j] = 0;
        else {
          G[aft] += G[j];
          G[j] = 0;
        }
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) cnt += G[i];
  cout << cnt << endl;
}
