#include <bits/stdc++.h>
using namespace std;
bool *judge(int N, int Q, string s, vector<char> t, vector<char> d) {
  bool *hoge = new bool[N];
  for (int i = 0; i < N; i++) hoge[i] = false;
  if (Q == 1) {
    if (s[0] == t[0] && d[0] == 'L') hoge[0] = true;
    if (s[N - 1] == t[0] && d[0] == 'R') hoge[N - 1] = true;
  } else {
    vector<char> tt, dd;
    tt = t;
    dd = d;
    tt.erase(tt.begin());
    dd.erase(dd.begin());
    bool *hogehoge = judge(N, Q - 1, s, tt, dd);
    for (int i = 0; i < N; i++) {
      if (s[i] == t[0]) {
        if (d[0] == 'L') {
          if (i == 0)
            hoge[0] = true;
          else if (hogehoge[i - 1])
            hoge[i] = true;
        } else {
          if (i == N - 1)
            hoge[N - 1] = true;
          else if (hogehoge[i + 1])
            hoge[i] = true;
        }
      } else if (hogehoge[i])
        hoge[i] = true;
    }
    delete[] hogehoge;
  }
  return hoge;
}
int main() {
  int N, Q;
  string s;
  cin >> N;
  cin >> Q;
  cin >> s;
  vector<char> t;
  vector<char> d;
  char nya;
  for (int i = 0; i < Q; i++) {
    cin >> nya;
    t.push_back(nya);
    cin >> nya;
    d.push_back(nya);
  }
  bool *hoge;
  hoge = judge(N, Q, s, t, d);
  int tot = 0;
  for (int i = 0; i < N; i++) {
    if (hoge[i]) tot++;
  }
  cout << N - tot << endl;
}
