#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
constexpr long long mod = 1e9 + 7;
constexpr long long Mod = 998244353;
constexpr long long MXN = 500000 + 100;
constexpr ld EPS = 1e-10;
constexpr ll inf = 3 * 1e18;
constexpr long long Inf = 15 * 1e8;
const vector<long long> dx{-1, 1, 0, 0}, dy{0, 0, -1, 1};
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;
}
ll read() {
  ll u, k = scanf("%lld", &u);
  return u;
}
string reads() {
  string s;
  cin >> s;
  return s;
}
pair<long long, long long> readh(bool g = 0) {
  pair<long long, long long> u;
  long long k = scanf("%lld %lld", &u.first, &u.second);
  if (g) u.first--, u.second--;
  return u;
}
bool ina(pair<long long, long long> t, long long h, long long w) {
  return 0 <= t.first && t.first < h && 0 <= t.second && t.second < w;
}
bool ina(long long t, long long l, long long r) { return l <= t && t < r; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll mod_pow(ll x, ll n, ll p = mod) {
  ll res = 1;
  x %= p;
  while (n > 0) {
    if (n & 1) res = res * x % p;
    x = x * x % p;
    n >>= 1;
  }
  return res;
}
ll bitcount(ll x) {
  long long sum = 0;
  for (long long i = 0; i < 60; i++)
    if ((1ll << i) & x) sum++;
  return sum;
}
long long n, q;
string s;
char t[300000], d[300000];
signed main() {
  cin >> n >> q >> s;
  for (long long i = (0); i < ((q)); i++) cin >> t[i] >> d[i];
  auto F = [&](long long x, long long y) -> bool {
    for (long long i = (0); i < ((q)); i++) {
      if (s[x] == t[i]) {
        if (d[i] == 'L')
          x--;
        else
          x++;
      }
      if (x == y) return 1;
      if (!ina(x, 0, n)) return 0;
    }
  };
  vector<long long> c(n);
  for (long long i = (0); i < ((n)); i++) c[i] = i;
  cout << partition_point((c).begin(), (c).end(),
                          [&](long long i) { return F(i, n) == 0; }) -
              partition_point((c).begin(), (c).end(),
                              [&](long long i) { return F(i, -1); })
       << endl;
}
