#include <bits/stdc++.h>
using namespace std;
string s;
int q, n;
char t[200000];
char d[200000];
int Serch(int check) {
  for (int i = 0; i < q; i++) {
    if (t[i] == s[check]) {
      if (d[i] == 'L') {
        check--;
      } else {
        check++;
      }
    }
    if (check < 0) {
      return -1;
    }
    if (check >= n) {
      return -2;
    }
  }
  return -3;
}
int main() {
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  int high = n;
  int low = 0;
  int left;
  while (high - low > 1) {
    left = (high + low) / 2;
    if (Serch(left) == -1) {
      low = left;
    } else {
      high = left;
    }
  }
  high = n;
  low = 0;
  int right;
  while (high - low > 1) {
    right = (high + low) / 2;
    if (Serch(right) == -2) {
      high = right;
    } else {
      low = right;
    }
  }
  cout << right - left + 1 << endl;
}
