#include <iostream>
#include <string>
#include <vector>
using namespace std;

struct Command {
  char t, d;
};
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<Command> commands;
  for (int i = 0; i < q; ++i) {
    char t, d;
    cin >> t >> d;
    commands.push_back((Command){t, d});
  }
  auto f = [&](int c) { 
    int cur = c;
    for (int i = 0; i < q; ++i) {
      if (commands[i].t != s[cur]) continue;
      if (commands[i].d == 'L') --cur;
      else ++cur;
      if (cur >= n || cur < 0) return cur;
    }
    return cur;
  };
  int l = -1, r = n;
  while (r-l>1) {
    int c = (l+r)/2;
    int nc = f(c);
    if (nc >= 0) r = c; else l = c;
  }
  // cerr << l << " " << r << endl;
  int min = l;
  l = -1, r = n;
  while (r-l>1) {
    int c = (l+r)/2;
    int nc = f(c);
    if (nc < n) l = c; else r = c;
  }
  int max = l;
  cout << max-min << endl;
}

