#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 10;
long long n, q;
string second;
pair<char, char> c[MAXN];
long long first(long long i) {
  long long ptr = i;
  for (long long j = 0; j < q; j++)
    if (c[j].first == second[ptr])
      if (c[j].second == 'L')
        ptr--;
      else
        ptr++;
  if (ptr < 0) return 0;
  if (ptr >= n) return 1;
  return 2;
}
int32_t main() {
  cin >> n >> q >> second;
  for (long long i = 0; i < q; i++) cin >> c[i].first >> c[i].second;
  long long l = -1, r = n + 1;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    if (first(mid) == 1)
      r = mid;
    else
      l = mid;
  }
  long long right = l;
  l = -1, r = n + 1;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    if (!first(mid))
      l = mid;
    else
      r = mid;
  }
  return cout << n - (n - 1 - right + 1) - (l + 1) + 1 << endl, 0;
}
