#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
constexpr long long mod = 1e9 + 7;
constexpr long long INF = mod;
constexpr int MAX = 200010;
int n, q;
string s;
char t[MAX], d[MAX];
int check(int mid) {
  for (int((i)) = (0); ((i)) < ((q)); ++((i))) {
    if (s[mid] == t[i]) d[i] == 'L' ? --mid : ++mid;
    if (mid < 0)
      return 1;
    else if (mid == n)
      return 2;
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &q);
  cin >> s;
  for (int((i)) = (0); ((i)) < ((q)); ++((i))) scanf(" %c %c", &t[i], &d[i]);
  int ans = n;
  int low = 0, high = n;
  if (check(low) == 1) {
    while (high - low > 1) {
      int mid = (high + low) / 2;
      (check(mid) == 1 ? low : high) = mid;
    }
  }
  ans -= low + 1;
  low = -1, high = n - 1;
  if (check(high) == 2) {
    while (high - low > 1) {
      int mid = (high + low) / 2;
      (check(mid) == 2 ? high : low) = mid;
    }
  }
  ans -= n - high;
  printf("%d\n", ans);
}
