#include <bits/stdc++.h>
int compare_int(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main() {
  int a, b, c;
  int A[2000001] = {};
  int B[2000001] = {};
  int ans[100003] = {};
  int sum[100003] = {};
  int cnt_flag[100003] = {};
  int L[1003] = {};
  long long d, X, Y;
  long long JPY;
  double BTC;
  char s[200001] = {};
  char t[200001] = {};
  char u[200001] = {};
  int i, j, k;
  int flag = 0;
  int tmp = 0;
  long long min = 10000000001;
  int len = 0;
  int cnt = 0;
  int cnt0 = 0;
  int cnt1 = 0;
  int num = 0;
  int max = 0;
  scanf("%d%d", &a, &b);
  scanf("%s", &s);
  for (i = 0; i < a; i++) {
    A[i]++;
  }
  for (i = 0; i < b; i++) {
    scanf("%s%s", &t[i], &u[i]);
    for (j = 0; j < a; j++) {
      if (t[i] == s[j]) {
        if (u[i] == 'L')
          B[j - 1] = A[j];
        else if (u[i] == 'R')
          B[j + 1] = A[j];
        A[j] = 0;
      }
    }
    for (j = 0; j < a; j++) {
      A[j] = B[j] + A[j];
      B[j] = 0;
    }
  }
  for (i = 0; i < a; i++) {
    cnt = cnt + A[i];
  }
  printf("%d\n", cnt);
  return 0;
}
