#include <bits/stdc++.h>
using namespace std;
void _main();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}
const int inf = INT_MAX / 2;
const long long infl = 1LL << 60;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int N, Q;
string S;
char T[201010], D[201010];
int check(int x) {
  for (int i = 0; i < Q; i++) {
    if (T[i] == S[x]) {
      if (D[i] == 'L')
        x--;
      else
        x++;
    }
    if (x < 0 or N <= x) return x;
  }
  return x;
}
void _main() {
  cin >> N >> Q >> S;
  for (int q = 0; q < Q; q++) cin >> T[q] >> D[q];
  int ans = N;
  if (check(0) < 0) {
    int ok = 0, ng = N;
    while (ok + 1 != ng) {
      int md = (ok + ng) / 2;
      if (check(md) < 0)
        ok = md;
      else
        ng = md;
    }
    ans -= ok + 1;
  }
  if (N <= check(N - 1)) {
    int ng = 0, ok = N - 1;
    while (ng + 1 != ok) {
      int md = (ok + ng) / 2;
      if (N <= check(md))
        ok = md;
      else
        ng = md;
    }
    ans -= N - ok;
  }
  cout << ans << endl;
}
