#include <bits/stdc++.h>
using namespace std;
int N, Q;
string S;
string T = "";
string D = "";
int f(int n) {
  for (auto i = 0; i < Q; i++) {
    if (S[n] == T[i]) {
      if (D[i] == 'L') {
        n--;
      } else {
        n++;
      }
    }
    if (!(0 <= n && n < N)) {
      return n;
    }
  }
  return n;
}
int main() {
  cin >> N >> Q >> S;
  for (auto i = 0; i < Q; i++) {
    string t, d;
    cin >> t >> d;
    T = T + t;
    D = D + d;
  }
  int ok = N;
  int ng = -1;
  while (abs(ok - ng) > 1) {
    int t = (ok + ng) / 2;
    if (f(t) == -1) {
      ng = t;
    } else {
      ok = t;
    }
  }
  int left = ok;
  ok = -1;
  ng = N;
  while (abs(ok - ng) > 1) {
    int t = (ok + ng) / 2;
    if (f(t) == N) {
      ng = t;
    } else {
      ok = t;
    }
  }
  int right = ok;
  cout << right - left + 1 << endl;
}
