#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<pair<char, char> > queries(q);
  char t, d;
  for (int i = 0; i < q; ++i) {
    cin >> queries[i].second >> queries[i].first;
  }
  int ng = -1, ok = n;
  while (ok - ng > 1) {
    int mid = (ok + ng) / 2;
    int si = mid;
    for (int i = 0; i < q && si >= 0 && si < n; ++i) {
      if (queries[i].first == 'L' && queries[i].second == s[si]) {
        --si;
      } else if (queries[i].first == 'R' && queries[i].second == s[si]) {
        ++si;
      }
    }
    if (si < 0) {
      ng = mid;
    } else {
      ok = mid;
    }
  }
  int l = ng + 1;
  ng = n;
  ok = l + 1;
  while (ng - ok > 1) {
    int mid = (ok + ng) / 2;
    int si = mid;
    for (int i = 0; i < q && si >= 0 && si < n; ++i) {
      if (queries[i].first == 'L' && queries[i].second == s[si]) {
        --si;
      } else if (queries[i].first == 'R' && queries[i].second == s[si]) {
        ++si;
      }
    }
    if (si >= n) {
      ng = mid;
    } else {
      ok = mid;
    }
  }
  int r = n - ng;
  cout << max(0, n - r - l) << endl;
}
