#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<pair<char, char>> V;
  char t, d;
  for (int i = 0; i < Q; i++) {
    cin >> t >> d;
    V.push_back(make_pair(t, d));
  }
  int left, right;
  for (int i = 0; i < N; i++) {
    int now = i;
    int flag = 0;
    int breakPos = -100;
    for (int j = 0; j < Q; j++) {
      if (S[now] == V[j].first) {
        if (V[j].second == 'L')
          now--;
        else
          now++;
        if (now < 0) {
          breakPos = j;
          flag = -1;
          break;
        }
        if (now >= N) {
          flag = 1;
          break;
        }
      }
    }
    if (flag == 0) {
      left = i;
      break;
    }
    if (flag == 1) {
      cout << 0 << endl;
      return 0;
    }
    if (flag == -1) {
      for (int j = breakPos; j >= 0; j--) {
        if (now + 1 < N && S[now + 1] == V[j].first && V[j].second == 'L') {
          now++;
          continue;
        }
        if (S[now] != V[j].first) {
          continue;
        }
        now--;
      }
      i = now;
    }
  }
  for (int i = N - 1; i >= 0; i--) {
    int now = i;
    int flag = 0;
    int breakPos = -100;
    for (int j = 0; j < Q; j++) {
      if (S[now] == V[j].first) {
        if (V[j].second == 'L')
          now--;
        else
          now++;
        if (now < 0) {
          flag = -1;
          break;
        }
        if (now >= N) {
          breakPos = j;
          flag = 1;
          break;
        }
      }
    }
    if (flag == 0) {
      right = i;
      break;
    }
    if (flag == 1) {
      for (int j = breakPos; j >= 0; j--) {
        if (now - 1 >= 0 && S[now - 1] == V[j].first && V[j].second == 'R') {
          now--;
          continue;
        }
        if (S[now] != V[j].first) {
          continue;
        }
        now++;
      }
      i = now;
    }
    if (flag == -1) {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << right - left + 1 << endl;
  return 0;
}
