#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<pair<char, char>> td(Q);
  for (int i = 0; i < Q; i++) cin >> td[i].first >> td[i].second;
  reverse(td.begin(), td.end());
  int l = -1, r = N;
  for (auto x : td) {
    if (x.second == 'L') {
      if (s[l + 1] == x.first) l++;
      if (s[r] == x.first) r++;
    } else {
      if (s[r - 1] == x.first) r--;
      if (s[l] == x.first) l--;
    }
    if (l == r - 1) break;
  }
  int ans = N - (l + 1 + N - r);
  cout << ans << endl;
  return 0;
}
