#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, q;
  std::cin >> n >> q;
  string s;
  std::cin >> s;
  vector<char> t(n), d(n);
  for (int i = 0; i < q; i++) {
    std::cin >> t[i] >> d[i];
  }
  long long l = -1;
  long long r = n;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    long long now = mid;
    bool ok = false;
    for (int i = 0; i < q; i++) {
      if (s[now] == t[i]) {
        if (d[i] == 'R') {
          now++;
        } else {
          now--;
        }
        if (now == -1) {
          ok = true;
          break;
        }
      }
    }
    if (ok) {
      l = mid;
    } else {
      r = mid;
    }
  }
  long long lcnt = l + 1;
  l = -1;
  r = n;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    long long now = mid;
    bool ok = false;
    for (int i = 0; i < q; i++) {
      if (s[n - 1 - now] == t[i]) {
        if (d[i] == 'R') {
          now--;
        } else {
          now++;
        }
        if (now == -1) {
          ok = true;
          break;
        }
      }
    }
    if (ok) {
      l = mid;
    } else {
      r = mid;
    }
  }
  std::cout << n - min(n, lcnt + l + 1) << std::endl;
}
