#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000 + 5;
int n, q;
string s;
pair<char, char> t[N];
int pos(int x) {
  if (x == -1) return 0;
  for (int i = 0; i < q; i++) {
    if (t[i].first == s[x]) {
      if (t[i].second == 'R')
        x++;
      else
        x--;
    }
    if (x >= n) return 2;
    if (x < 0) return 0;
  }
  return 1;
}
int main() {
  cin >> n;
  cin >> q;
  cin >> s;
  for (int i = 0; i < q; i++) {
    cin >> t[i].first;
    cin >> t[i].second;
  }
  int dw = -1, up = n;
  while (up - dw > 1) {
    int md = (dw + up) / 2;
    if (pos(md) == 0) {
      dw = md;
    } else {
      up = md;
    }
  }
  int ndw = -1, nup = n;
  cout << 7 << endl;
  return 0;
  while (nup - ndw > 1) {
    int nmd = (ndw + nup) / 2;
    if (pos(nmd) <= 1) {
      ndw = nmd;
    } else {
      nup = nmd;
    }
  }
  cout << ndw - dw << endl;
  return 0;
}
