#include <bits/stdc++.h>
int rrdata(unsigned char a);
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  int akazu[200001] = {1};
  char s[200001] = {'0'};
  char t[200001] = {'0'};
  char d[200001] = {'0'};
  int bkazu[26] = {0};
  int kazu[26][200001] = {200001};
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    akazu[i] = 1;
    switch (s[i]) {
      case 'A':
        kazu[0][bkazu[0]] = i;
        bkazu[0]++;
        break;
      case 'B':
        kazu[1][bkazu[1]] = i;
        bkazu[1]++;
        break;
      case 'C':
        kazu[2][bkazu[2]] = i;
        bkazu[2]++;
        break;
      case 'D':
        kazu[3][bkazu[3]] = i;
        bkazu[3]++;
        break;
      case 'E':
        kazu[4][bkazu[4]] = i;
        bkazu[4]++;
        break;
      case 'F':
        kazu[5][bkazu[5]] = i;
        bkazu[5]++;
        break;
      case 'G':
        kazu[6][bkazu[6]] = i;
        bkazu[6]++;
        break;
      case 'H':
        kazu[7][bkazu[7]] = i;
        bkazu[7]++;
        break;
      case 'I':
        kazu[8][bkazu[8]] = i;
        bkazu[8]++;
        break;
      case 'J':
        kazu[9][bkazu[9]] = i;
        bkazu[9]++;
        break;
      case 'K':
        kazu[10][bkazu[10]] = i;
        bkazu[10]++;
        break;
      case 'L':
        kazu[11][bkazu[11]] = i;
        bkazu[11]++;
        break;
      case 'M':
        kazu[12][bkazu[12]] = i;
        bkazu[12]++;
        break;
      case 'N':
        kazu[13][bkazu[13]] = i;
        bkazu[13]++;
        break;
      case 'O':
        kazu[14][bkazu[14]] = i;
        bkazu[14]++;
        break;
      case 'P':
        kazu[15][bkazu[15]] = i;
        bkazu[15]++;
        break;
      case 'Q':
        kazu[16][bkazu[16]] = i;
        bkazu[16]++;
        break;
      case 'R':
        kazu[17][bkazu[17]] = i;
        bkazu[17]++;
        break;
      case 'S':
        kazu[18][bkazu[18]] = i;
        bkazu[18]++;
        break;
      case 'T':
        kazu[19][bkazu[19]] = i;
        bkazu[19]++;
        break;
      case 'U':
        kazu[20][bkazu[20]] = i;
        bkazu[20]++;
        break;
      case 'V':
        kazu[21][bkazu[21]] = i;
        bkazu[21]++;
        break;
      case 'W':
        kazu[22][bkazu[22]] = i;
        bkazu[22]++;
        break;
      case 'X':
        kazu[23][bkazu[23]] = i;
        bkazu[23]++;
        break;
      case 'Y':
        kazu[24][bkazu[24]] = i;
        bkazu[24]++;
        break;
      case 'Z':
        kazu[25][bkazu[25]] = i;
        bkazu[25]++;
        break;
      default:
        break;
    }
  }
  for (int i = 0; i < q; i++) {
    scanf("%s%s", &t[i], &d[i]);
    if (d[i] == 'L') {
      for (int j = 0; j < bkazu[rrdata(t[i])]; j++) {
        if (kazu[rrdata(t[i])][j] == 0) {
          akazu[0] = 0;
        } else {
          akazu[kazu[rrdata(t[i])][j] - 1] =
              akazu[kazu[rrdata(t[i])][j] - 1] + akazu[kazu[rrdata(t[i])][j]];
          akazu[kazu[rrdata(t[i])][j]] = 0;
        }
      }
    } else {
      for (int j = bkazu[rrdata(t[i])] - 1; j >= 0; j--) {
        if (kazu[rrdata(t[i])][j] == bkazu[rrdata(t[i])] - 1) {
          akazu[bkazu[rrdata(t[i])] - 1] = 0;
        } else {
          akazu[kazu[rrdata(t[i])][j] + 1] =
              akazu[kazu[rrdata(t[i])][j] + 1] + akazu[kazu[rrdata(t[i])][j]];
          akazu[kazu[rrdata(t[i])][j]] = 0;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = akazu[i] + ans;
  }
  printf("%d\n", ans);
  return 0;
}
int rrdata(unsigned char a) {
  switch (a) {
    case 'A':
      return 0;
      break;
    case 'B':
      return 1;
      break;
    case 'C':
      return 2;
      break;
    case 'D':
      return 3;
      break;
    case 'E':
      return 4;
      break;
    case 'F':
      return 5;
      break;
    case 'G':
      return 6;
      break;
    case 'H':
      return 7;
      break;
    case 'I':
      return 8;
      break;
    case 'J':
      return 9;
      break;
    case 'K':
      return 10;
      break;
    case 'L':
      return 11;
      break;
    case 'M':
      return 12;
      break;
    case 'N':
      return 13;
      break;
    case 'O':
      return 14;
      break;
    case 'P':
      return 15;
      break;
    case 'Q':
      return 16;
      break;
    case 'R':
      return 17;
      break;
    case 'S':
      return 18;
      break;
    case 'T':
      return 19;
      break;
    case 'U':
      return 20;
      break;
    case 'V':
      return 21;
      break;
    case 'W':
      return 22;
      break;
    case 'X':
      return 23;
      break;
    case 'Y':
      return 24;
      break;
    case 'Z':
      return 25;
      break;
    default:
      break;
  }
}
