#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  vector<tuple<char, int>> T;
  for (long long i = 0; i < N; i++) {
    char t, d;
    cin >> t >> d;
    T.push_back(make_tuple(t, d == 'R' ? 1 : -1));
  }
  long long L = -1;
  long long R = N;
  while (R - L > 1) {
    int M = (L + R) / 2;
    int cur = M;
    bool ok = false;
    for (int i = 0; i < K; i++) {
      if (S[cur] == get<0>(T[i])) cur += get<1>(T[i]);
      if (cur == N) break;
      if (cur == -1) {
        ok = true;
        break;
      }
    }
    if (ok)
      L = M;
    else
      R = M;
  }
  int kek = L;
  L = -1;
  R = N;
  while (R - L > 1) {
    int M = (L + R) / 2;
    int cur = M;
    bool ok = false;
    for (int i = 0; i < K; i++) {
      if (S[cur] == get<0>(T[i])) cur += get<1>(T[i]);
      if (cur == -1) break;
      if (cur == N) {
        ok = true;
        break;
      }
    }
    if (ok)
      R = M;
    else
      L = M;
  }
  if (kek >= R)
    cout << 0 << endl;
  else
    cout << R - kek - 1 << endl;
  return 0;
}
