#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9 + 7;
const int limit = 200005;
int N, Q;
string s;
char t[limit], d[limit];
int g[limit], ng[limit];
int solve0() {
  for (int i = (0); i < (N); ++i) g[i] = 1;
  for (int i = (0); i < (Q); ++i) {
    for (int j = (0); j < (N); ++j) ng[j] = 0;
    for (int j = (0); j < (N); ++j) {
      if (s[j] == t[i]) {
        if (d[i] == 'L' && j > 0)
          ng[j - 1] += g[j];
        else if (d[i] == 'R' && j + 1 < N)
          ng[j + 1] += g[j];
      } else
        ng[j] += g[j];
    }
    for (int j = (0); j < (N); ++j) g[j] = ng[j];
  }
  int ans = 0;
  for (int i = (0); i < (N); ++i) ans += g[i];
  return ans;
}
int emu(int k) {
  int idx = k;
  for (int i = (0); i < (Q); ++i) {
    if (s[idx] == t[i]) idx += (d[i] == 'L' ? -1 : 1);
    if (idx < 0 || N <= idx) break;
  }
  return idx;
}
int solve1() {
  int ans = 0, ng, ok;
  ng = -1;
  ok = N;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (emu(mid) >= 0)
      ok = mid;
    else
      ng = mid;
  }
  ans += ng + 1;
  ng = -1;
  ok = N;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (emu(mid) >= N)
      ok = mid;
    else
      ng = mid;
  }
  ans += N - ok;
  return N - ans;
}
int solve2() {
  int l = 0, r = N - 1;
  for (int i = (Q)-1; i >= (0); --i) {
    if (s[l] == t[i] && d[i] == 'L') ++l;
    if (s[r] == t[i] && d[i] == 'R') --r;
    if (r < l) return 0;
  }
  return r - l + 1;
}
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> N >> Q;
  cin >> s;
  for (int i = (0); i < (Q); ++i) cin >> t[i] >> d[i];
  cout << solve2() << '\n';
  return 0;
}
