#include <bits/stdc++.h>
using namespace std;
int lef, rig;
int n, q;
string s;
char t[200001], d[200001];
int main() {
  cin >> n >> q;
  cin >> s;
  int lr, long long int;
  for (int i = 0; i < (int)(q); i++) cin >> t[i] >> d[i];
  lef = 0, rig = n - 1;
  for (int j = 0; j < (int)(35); j++) {
    int mid = (lef + rig) / 2;
    for (int i = 0; i < (int)(q); i++) {
      if (s.at(mid) == t[i]) {
        if (d[i] == 'L')
          mid--;
        else
          mid++;
      }
      if (mid < 0 || mid > n - 1) break;
    }
    if (mid < 0)
      lef = (lef + rig) / 2;
    else
      rig = (lef + rig) / 2;
  }
  long long int = lef;
  lef = 0, rig = n - 1;
  for (int j = 0; j < (int)(35); j++) {
    int mid = (lef + rig) / 2;
    for (int i = 0; i < (int)(q); i++) {
      if (s.at(mid) == t[i]) {
        if (d[i] == 'L')
          mid--;
        else
          mid++;
      }
      if (mid < 0 || mid > n - 1) break;
    }
    if (mid > n - 1)
      rig = (lef + rig) / 2;
    else
      lef = (lef + rig) / 2;
  }
  lr = rig;
  cout << lr - long long int << endl;
}
