#include <bits/stdc++.h>
using namespace std;
int v[200010];
vector<int> t[60];
int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);
  char s[200010];
  for (int i = 1; i <= N; i++) {
    cin >> s[i];
  }
  int num = N;
  for (int i = 1; i <= N; i++) {
    v[i] = 1;
    if (s[i] >= 'a' && s[i] <= 'z') {
      t[(s[i] - 'a' + 1)].push_back(i);
    } else if (s[i] >= 'A' && s[i] <= 'Z') {
      t[s[i] - 'A' + 1 + 26].push_back(i);
    }
  }
  for (int i = 1; i <= Q; i++) {
    char a, b;
    cin >> a >> b;
    if (a >= 'a' && a <= 'z') {
      int x = a - 'a' + 1;
      for (int j = 0; j < t[x].size(); j++) {
        if (b == 'R' && t[x][j] == N || b == 'L' && t[x][j] == 1) {
          num -= v[t[x][j]];
          v[t[x][j]] = 0;
        } else if (b == 'R') {
          v[t[x][j] + 1] += v[t[x][j]];
          v[t[x][j]] = 0;
        } else if (b == 'L') {
          v[t[x][j] - 1] += v[t[x][j]];
          v[t[x][j]] = 0;
        }
      }
    } else if (a >= 'A' && a <= 'Z') {
      int y = a - 'A' + 1 + 26;
      for (int j = 0; j < t[y].size(); j++) {
        if (b == 'R' && t[y][j] == N || b == 'L' && t[y][j] == 1) {
          num -= v[t[y][j]];
          v[t[y][j]] = 0;
        } else if (b == 'R') {
          v[t[y][j] + 1] += v[t[y][j]];
          v[t[y][j]] = 0;
        } else if (b == 'L') {
          v[t[y][j] - 1] += v[t[y][j]];
          v[t[y][j]] = 0;
        }
      }
    }
  }
  printf("%d\n", num);
  return 0;
}
