#include <bits/stdc++.h>
using namespace std;
long long Mod = 1e9 + 7;
int N, Q;
string S;
vector<char> s, t;
int isDropped(int now) {
  for (int i = 0; i < Q; i++) {
    if (now != -1 && now != N && S[i] == t[i]) {
      if (s[i] == 'R')
        now++;
      else
        now--;
    }
  }
  if (now == -1)
    return -1;
  else if (now == N)
    return 1;
  else
    return 0;
};
int main() {
  cin >> N >> Q;
  cin >> S;
  for (int i = 0; i < Q; i++) {
    char a, b;
    cin >> a >> b;
    s.push_back(a);
    t.push_back(b);
  }
  int left = 0, right = N;
  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (isDropped(mid) >= 0) {
      right = mid;
    } else {
      left = mid;
    }
  }
  int LE = right;
  left = 0;
  right = N;
  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (isDropped(mid) <= 0) {
      left = mid;
    } else {
      right = mid;
    }
  }
  int RE = left;
  cout << RE - LE + 1 << endl;
  return 0;
}
