#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long long int n, q;
  std::cin >> n >> q;
  string s;
  std::cin >> s;
  vector<vector<char>> t = vector<vector<char>>(q, vector<char>(2, 0));
  for (int i = 0; i < q; i++) std::cin >> t[i][0] >> t[i][1];
  long long int l = -1, r = n;
  while (r - l > 1) {
    long long int mid = (l + r) / 2;
    long long int now = mid;
    for (long long int i = 0; i < q; i++)
      if (now >= 0 && now < n && s[now] == t[i][0])
        now = now + (t[i][1] == 'L' ? -1 : 1);
    if (now < 0)
      l = mid;
    else
      r = mid;
  }
  long long int ok_right = r;
  l = 0, r = n + 1;
  while (r - l > 1) {
    long long int mid = (l + r) / 2;
    long long int now = mid;
    for (long long int i = 0; i < q; i++)
      if (now >= 0 && now < n && s[now] == t[i][0])
        now = now + (t[i][1] == 'L' ? -1 : 1);
    if (now >= n)
      r = mid;
    else
      l = mid;
  }
  std::cout << max(l - ok_right + 1, (long long int)0) << '\n';
  return 0;
}
