#include <bits/stdc++.h>
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;
}
using namespace std;
bool isFall(string &s, vector<pair<char, char>> &cmd, long long pos,
            char goal) {
  bool ret = false;
  long long cmdSize = cmd.size();
  for (long long i = 0, i_len = (long long)(cmdSize); i < i_len; i++) {
    if (cmd[i].first == s[pos]) {
      cmd[i].second == 'R' ? pos++ : pos--;
      if (pos < 0 || pos > s.size() - 1) break;
    }
  }
  if ((pos < 0 && goal == 'L') || (pos > s.size() - 1 && goal == 'R'))
    ret = true;
  return ret;
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout << fixed << setprecision(15);
  ;
  long long n, q;
  string s;
  cin >> n >> q >> s;
  vector<pair<char, char>> cmd(q);
  for (long long i = 0, i_len = (long long)(q); i < i_len; i++)
    cin >> cmd[i].first >> cmd[i].second;
  long long l = -1, r = n;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    (isFall(s, cmd, mid, 'L') ? l : r) = mid;
  }
  long long ans = n - (l != -1 ? (l + 1) : 0);
  l = -1, r = n;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    (isFall(s, cmd, mid, 'R') ? r : l) = mid;
  }
  cout << ans - (r != n ? (n - r) : 0) << "\n";
}
