#include <bits/stdc++.h>
using namespace std;
int N, Q;
string str;
vector<char> t, d;
int is_down(int k) {
  int pos = k;
  for (int i = 0; i < Q; i++) {
    if (pos == -1 || pos == N) return pos;
    if (str[pos] == t[i]) {
      if (d[i] == 'L')
        pos--;
      else
        pos++;
    }
  }
  return pos;
}
int main() {
  cin >> N >> Q;
  cin >> str;
  for (int i = 0; i < Q; i++) {
    char tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    t.push_back(tmp1);
    d.push_back(tmp2);
  }
  int left = 0, right = N - 1;
  while (left < right) {
    int mid = (left + right) / 2;
    if (is_down(mid) == -1)
      left = mid + 1;
    else
      right = mid - 1;
  }
  int remainL = left;
  left = 0, right = N - 1;
  while (left < right) {
    int mid = (left + right) / 2;
    if (is_down(mid) == N)
      right = mid - 1;
    else
      left = mid + 1;
  }
  int remainR = right;
  int ans = remainR - remainL;
  cout << ans << endl;
  return 0;
}
