#include <bits/stdc++.h>
using namespace std;
int n, q;
vector<int> go;
vector<char> t, d;
string s;
int posi(int ind) {
  vector<int> l_go = vector<int>(go);
  for (size_t i = 0; i < q; i++) {
    if (l_go[ind] < 0) {
      return -1;
    } else if (l_go[ind] > n - 1) {
      return n;
    }
    if (s[l_go[ind]] == t[i]) {
      if (d[i] == 'R')
        l_go[ind] += 1;
      else
        l_go[ind] -= 1;
    }
  }
  return l_go[ind];
}
int binsearch_zero(int first, int last) {
  while (first < last) {
    int mid = (first + last) / 2;
    int p = posi(mid);
    if (p == 0) {
      return mid;
    } else if (p > 0) {
      last = mid;
    } else {
      first = mid + 1;
    }
  }
  return first;
}
int binsearch_n(int first, int last) {
  if (first == last) return first - 1;
  int mid = (first + last) / 2;
  int p = posi(mid);
  if (p == n - 1) {
    return mid;
  } else if (p > n - 1) {
    return binsearch_n(first, mid);
  } else {
    return binsearch_n(mid + 1, last);
  }
}
int main() {
  int sum = 0;
  cin >> n >> q >> s;
  vector<int> l_go(n);
  vector<char> l_t(q), l_d(q);
  for (size_t i = 0; i < n; i++) {
    l_go[i] = i;
  }
  go = l_go;
  for (size_t i = 0; i < q; i++) {
    cin >> l_t[i] >> l_d[i];
  }
  t = l_t;
  d = l_d;
  int b_z = binsearch_zero(0, n - 1);
  int b_n = binsearch_n(0, n - 1);
  cout << b_n - b_z + 1 << endl;
}
