#include <bits/stdc++.h>
int main(void) {
  int N, Q, masu[200100], i, j, idou[200100], sum = 0;
  char s[200100], t[200100], d[200100];
  scanf("%d", &N);
  scanf("%d", &Q);
  scanf("%s", s);
  for (i = 0; i < Q; i++) {
    scanf("%c", &t[i]);
    scanf("%c", &d[i]);
  }
  for (i = 0; i < N; i++) {
    masu[i] = 1;
  }
  for (i = 0; i < Q; i++) {
    for (j = 0; j < N; j++) {
      if (s[j] == t[i]) {
        idou[j] = masu[j];
      }
      if (j == 0) {
        if (d[i] == 'L') {
          masu[j] = 0;
        } else if (d[i] == 'R') {
          masu[j] -= idou[j];
          masu[j + 1] += idou[j];
        }
      } else if (j == N - 1) {
        if (d[i] == 'L') {
          masu[j] -= idou[j];
          masu[j - 1] += idou[j];
        } else if (d[i] == 'R') {
          masu[j] = 0;
        }
      } else {
        if (d[i] == 'L') {
          masu[j] -= idou[j];
          masu[j - 1] += idou[j];
        } else if (d[i] == 'R') {
          masu[j] -= idou[j];
          masu[j + 1] += idou[j];
        }
      }
    }
  }
  for (i = 0; i < N; i++) {
    sum += masu[i];
  }
  printf("%d", sum);
  return 0;
}
