#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<pair<char, long long>> a(q);
  for (int i = 0; i < q; i++) {
    char dir;
    cin >> a[i].first >> dir;
    if (dir == 'L')
      a[i].second = -1;
    else
      a[i].second = 1;
  }
  long long res = 0;
  long long l = 0;
  long long r = n - 1;
  while (1) {
    if (r - l <= 1) break;
    long long mid = (r + l) / 2;
    long long now = mid;
    bool left = false;
    for (int i = 0; i < q; i++) {
      if (a[i].first == s[now]) now += a[i].second;
      if (now >= n) break;
      if (now < 0) {
        left = true;
        break;
      }
    }
    if (left)
      l = mid;
    else
      r = mid;
  }
  res += r;
  l = -1;
  r = n;
  while (1) {
    if (r - l <= 1) break;
    long long mid = (r + l) / 2;
    long long now = mid;
    bool right = false;
    for (int i = 0; i < q; i++) {
      if (a[i].first == s[now]) now += a[i].second;
      if (now < 0) break;
      if (now >= n) {
        right = true;
        break;
      }
    }
    if (right)
      r = mid;
    else
      l = mid;
  }
  res += n - r;
  cout << n - res << endl;
}
