#include <bits/stdc++.h>
using namespace std;
long long N, Q;
vector<pair<char, char>> golem;
string s;
long long check(long long num) {
  if (num >= N)
    return 1;
  else if (num < 0)
    return -1;
  for (long long i = 0; i < Q; i++) {
    if (s[num] == golem[i].first) {
      if (golem[i].second == 'R')
        num++;
      else
        num--;
    }
    if (num >= N) return 1;
    if (num < 0) return -1;
  }
  return 0;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  char t, d;
  cin >> N >> Q;
  cin >> s;
  for (long long i = 0; i < Q; i++) {
    cin >> t >> d;
    golem.push_back(make_pair(t, d));
  }
  long long low = -1, high = N + 1, m, ans = 0;
  while (low + 1 < high) {
    m = (low + high) / 2;
    if (check(m) == -1)
      low = m;
    else
      high = m;
  }
  ans = m;
  low = -1, high = N + 1;
  while (low + 1 < high) {
    m = (low + high) / 2;
    if (check(m) != 1)
      low = m;
    else
      high = m;
  }
  ans = N - (ans + N - m);
  cout << ans << "\n";
  return 0;
}
