#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<char> t(q), d(q);
  for (int i = 0; i < (q); ++i) cin >> t.at(i) >> d.at(i);
  int l = -1, r = n;
  while (r - l > 1) {
    int mid = (r + l + 1) / 2;
    bool flg = false;
    for (int i = 0; i < (q); ++i) {
      if (mid >= 0 && mid < n && t.at(i) == s.at(mid)) {
        if (d.at(i) == 'L')
          mid--;
        else
          mid++;
      }
      if (mid < 0) {
        flg = true;
        break;
      }
      if (mid >= n) break;
    }
    if (flg)
      l = (r + l + 1) / 2;
    else
      r = (r + l + 1) / 2;
  }
  int l1 = l;
  l = -1;
  r = n;
  while (r - l > 1) {
    int mid = (r + l + 1) / 2;
    bool flg = false;
    for (int i = 0; i < (q); ++i) {
      if (mid >= 0 && mid < n && t.at(i) == s.at(mid)) {
        if (d.at(i) == 'L')
          mid--;
        else
          mid++;
      }
      if (mid >= n) {
        flg = true;
        break;
      }
      if (mid < 0) break;
    }
    if (flg)
      r = (r + l + 1) / 2;
    else
      l = (r + l + 1) / 2;
  }
  l = l1;
  if (l >= r)
    cout << 0 << endl;
  else
    cout << n - (l + 1) - (n - (r + 1)) - 2 << endl;
}
