#include <bits/stdc++.h>
using namespace std;
template <class T>
using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
char moji[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
char moji2[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                  'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                  'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
char moji3[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
char chara[long long(2 * 1e5 + 5)];
char houkou[long long(2 * 1e5 + 5)];
long long n, q;
string s;
bool solve(long long x) {
  if (x < 0) return false;
  long long now = x;
  for (long long i = 0; i < q; i++) {
    if (s[now] == chara[i]) {
      if (houkou[i] == 'L') {
        now--;
        if (now < 0) return false;
      } else {
        now++;
      }
    }
  }
  return true;
}
bool solve2(long long x) {
  if (x >= n) return false;
  long long now = x;
  for (long long i = 0; i < q; i++) {
    if (s[now] == chara[i]) {
      if (houkou[i] == 'L') {
        now--;
      } else {
        now++;
        if (now >= n) return false;
      }
    }
  }
  return true;
}
signed main() {
  cin >> n >> q;
  cin >> s;
  for (long long i = 0; i < q; i++) {
    cin >> chara[i] >> houkou[i];
  }
  long long lef = -1, rig = n - 1;
  while (lef + 1 < rig) {
    long long mid = (lef + rig) / 2;
    if (solve(mid))
      rig = mid;
    else
      lef = mid;
  }
  long long leftans = lef;
  if (not solve2(leftans + 1)) {
    cout << 0 << endl;
    return 0;
  }
  lef = leftans + 1;
  rig = n;
  while (lef + 1 < rig) {
    long long mid = (lef + rig) / 2;
    if (solve2(mid))
      lef = mid;
    else
      rig = mid;
  }
  long long rightans = rig;
  cout << n - (leftans + 1) - (n - rightans) << endl;
}
