#include <bits/stdc++.h>
using namespace std;
int N, Q;
const int maxn = 200005;
vector<int> c_pos[256];
vector<char> insr;
int get_int() {
  int x;
  scanf("%d", &x);
  return x;
}
double get_double() {
  double x;
  scanf("%lf", &x);
  return x;
}
long long get_long() {
  long long x;
  scanf("%lld", &x);
  return x;
}
vector<char> vc;
void tests() { ; }
int sl(char ch, int pos) {
  int l = 0;
  while (true) {
    auto posnext = lower_bound(c_pos[ch].begin(), c_pos[ch].end(), l);
    if (posnext == c_pos[ch].end()) return 0;
    int index = (*posnext);
    if (insr[index] == 'L') {
      if (pos == 0) {
        return 1;
      } else {
        pos--;
        ch = vc[pos];
      }
    }
    if (insr[index] == 'R') {
      if (pos == N - 1) {
        return 1;
      } else {
        pos++;
        ch = vc[pos];
      }
    }
    l = index + 1;
  }
}
int main() {
  ios::sync_with_stdio(false);
  scanf("%d %d", &N, &Q);
  getchar();
  for (int i = (0); i < (N); i++) {
    char ch = getchar();
    vc.push_back(ch);
  }
  int k = 0;
  for (int i = (0); i < (Q); i++) {
    string s;
    string instr;
    cin >> s >> instr;
    char ch = s[0];
    char is = instr[0];
    insr.push_back(is);
    c_pos[ch].push_back(i);
  }
  for (int i = (0); i < (N); i++) {
    char ch = vc[i];
    int lefts = sl(ch, i);
    if (lefts) {
      k++;
    }
  }
  printf("%d\n", N - k);
  return 0;
}
