#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 extincted[200000];
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<char> left, right;
  char t, d;
  while (q--) {
    cin >> t >> d;
    if (d == 'L') {
      left.push_back(t);
    } else {
      right.push_back(t);
    }
  }
  int si = 0, ans = n;
  for (int i = left.size() - 1; i >= 0; --i) {
    if (si < n && left[i] == s[si]) {
      ++si;
    }
  }
  ans -= si;
  si = n - 1;
  for (int i = right.size() - 1; i >= 0; --i) {
    if (si >= 0 && right[i] == s[si]) {
      --si;
    }
  }
  ans -= n - 1 - si;
  cout << max(0, ans) << endl;
}
