// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<char> t(q);
  vector<char> d(q);
  for(int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }

  auto check = [&](int i) {
    for(int j = 0; j < q; j++) {
      if(s[i] == t[j]) {
        if(d[j] == 'L') i--;
        else i++;
      }
      if(i == -1 || i == n) break;
    }
    return i;
  };

  int ans = 0;

  int ok, ng;
  ok = -1, ng = n;
  while(abs(ok - ng) > 1) {
    int mid = (ok + ng) >> 1;
    if(check(mid) == -1) ok = mid;
    else ng = mid;
  }
  ans = ok + 1;

  ok = n, ng = -1;
  while(abs(ok - ng) > 1) {
    int mid = (ok + ng) >> 1;
    if(check(mid) == n) ok = mid;
    else ng = mid;
  }

  ans += n - ok;

  cout << n - ans << endl;
  return 0;
}
