#include <bits/stdc++.h>
using namespace std;
long long N, Q;
string s;
map<long long, long long> memo;
long long goal(long long pos, vector<char>& t, vector<char>& d) {
  if (memo.count(pos) > 0) return memo[pos];
  for (long long i = 0, i_len = (Q); i < i_len; ++i) {
    if (s[pos] == t[i]) {
      d[i] == 'L' ? pos-- : pos++;
    }
    if (pos < 0) {
      return memo[pos] = 1;
    }
    if (pos >= N) {
      return memo[pos] = 2;
    }
  }
  return memo[pos] = 0;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> N >> Q;
  cin >> s;
  vector<char> t(Q), d(Q);
  for (long long i = 0, i_len = (Q); i < i_len; ++i) {
    cin >> t[i] >> d[i];
  }
  if (goal(0, t, d) == 2 || goal(N - 1, t, d) == 1) {
    return 0;
  }
  long long res = 0;
  if (goal(0, t, d) == 1) {
    long long l = 0;
    long long r = N - 1;
    while (r - l > 1) {
      long long m = (l + r) / 2;
      if (goal(m, t, d) == 1) {
        l = m;
      } else {
        r = m;
      }
    }
    res += l + 1;
  }
  if (goal(N - 1, t, d) == 2) {
    long long l = 0;
    long long r = N - 1;
    while (r - l > 1) {
      long long m = (l + r) / 2;
      if (goal(m, t, d) == 2) {
        r = m;
      } else {
        l = m;
      }
    }
    res += N - r;
  }
  cout << N - res << endl;
  return 0;
}
