#include <bits/stdc++.h>
using namespace std;
int is_disappear(int n, string s, int idx, vector<char> t, vector<char> d) {
  int index = idx;
  for (size_t i = 0; i < (int)t.size(); i++) {
    if (t.at(i) == s.at(idx)) {
      if (d.at(i) == 'R')
        idx++;
      else
        idx--;
    }
    if (idx < 0)
      return 1;
    else if (idx >= n)
      return 2;
  }
  return -1;
}
int main(int argc, char const *argv[]) {
  int n, q;
  std::cin >> n >> q;
  string s;
  std::cin >> s;
  vector<char> t;
  vector<char> d;
  for (size_t i = 0; i < q; i++) {
    char tmpt, tmpd;
    std::cin >> tmpt >> tmpd;
    t.push_back(tmpt);
    d.push_back(tmpd);
  }
  int left = 0;
  int right = n - 1;
  int mid;
  while (true) {
    mid = (left + right) / 2;
    if (left == mid || right == mid) break;
    int ret_mid = is_disappear(n, s, mid, t, d);
    if (ret_mid == 1) {
      left = mid;
    } else {
      right = mid;
    }
  }
  int left_ans;
  if (left == 0) {
    if (is_disappear(n, s, 0, t, d) != -1)
      left_ans = 1;
    else
      left_ans = 0;
  } else {
    left_ans = left;
  }
  left = 0;
  right = n - 1;
  while (true) {
    mid = (left + right) / 2;
    if (left == mid || right == mid) break;
    int ret_mid = is_disappear(n, s, mid, t, d);
    if (ret_mid == 2) {
      right = mid;
    } else {
      left = mid;
    }
  }
  int right_ans;
  if (right == n - 1) {
    if (is_disappear(n, s, n - 1, t, d) != -1)
      right_ans = n - 2;
    else
      right_ans = n - 1;
  } else {
    right_ans = right;
  }
  std::cout << n - ((n - 1 - right_ans) + (left_ans - 1)) << '\n';
}
