#include <bits/stdc++.h>
using namespace std;
const int MAX = 16;
int main() {
  int N, Q;
  static char t[MAX], d[MAX];
  string s;
  cin >> N >> Q >> s;
  for (int i = 0; i < Q; ++i) cin >> t[i] >> d[i];
  static bitset<10> last, next;
  queue<int> check;
  check.push(-1);
  check.push(N);
  for (int i = Q - 1; i >= 0; --i) {
    queue<int> swap;
    while (!check.empty()) {
      int tmp = check.front();
      check.pop();
      if (tmp < N - 1 && t[i] == s[tmp + 1] && d[i] == 'L') {
        next[tmp + 1] = tmp >= 0 ? last[tmp] : true;
        swap.push(tmp + 1);
      }
      if (tmp > 0 && t[i] == s[tmp - 1] && d[i] == 'R') {
        next[tmp - 1] = tmp < N ? last[tmp] : true;
        swap.push(tmp - 1);
      }
      if (0 <= tmp && tmp < N && t[i] == s[tmp]) {
        if (tmp < N - 1 && d[i] == 'R') {
          next[tmp] = last[tmp + 1];
          swap.push(tmp);
        } else if (0 < tmp && d[i] == 'L') {
          next[tmp] = last[tmp - 1];
          swap.push(tmp);
        }
      }
      if (!(1 <= tmp && tmp < N - 1 && next[tmp - 1] && next[tmp] &&
            next[tmp + 1]))
        swap.push(tmp);
    }
    last = next;
    check = swap;
  }
  cout << N - last.count();
  return 0;
}
