#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
int N, Q;
string s;
int L[26], R[26];
char t[200000], d[200000];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> Q;
  cin >> s;
  for (long long int i = long long int(0); i < long long int(Q); i++) {
    cin >> t[i] >> d[i];
  }
  long long int pos = 0;
  long long int res = 0;
  for (long long int i = long long int(Q) - 1; i >= long long int(0); i--) {
    if (t[i] == s[pos] && d[i] == 'L') {
      pos++;
    } else if (t[i] == s[pos - 1] && d[i] == 'R') {
      res = max(res, pos);
      pos = 0;
    }
  }
  res = max(res, pos);
  pos = 0;
  long long int rres = 0;
  for (long long int i = long long int(Q) - 1; i >= long long int(0); i--) {
    if (t[i] == s[N - 1 - pos] && d[i] == 'R') {
      pos++;
    } else if (t[i] == s[N - pos] && d[i] == 'L') {
      rres = max(rres, pos);
      pos = 0;
    }
  }
  rres = max(rres, pos);
  cout << N - res - rres << "\n";
}
