#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, Q;
  cin >> N >> Q;
  char s[N];
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  char t;
  char d;
  char world[N][2];
  for (int i = 0; i < N; i++) {
    world[i][0] = s[i];
    world[i][1] = 1;
  }
  for (int i = 0; i < Q; i++) {
    cin >> t >> d;
    for (int j = 0; j < N; j++) {
      if (world[j][0] == t) {
        if (d == 'L') {
          if (j > 0) world[j - 1][1] = world[j - 1][1] + world[j][1];
        } else {
          if (j < N - 1) world[j + 1][1] = world[j + 1][1] + world[j][1];
        }
        world[j][1] = 0;
      }
    }
  }
  int total = 0;
  for (int i = 0; i < N; i++) {
    total = total + world[i][1];
  }
  cout << total << endl;
}
