#include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
const int N = 300000;
char t[N], d[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> q;
  cin >> s;
  for (int i = 1; i <= q; i++) {
    cin >> t[i] >> d[i];
  }
  int l = 0;
  int r = n;
  while (r - l > 0) {
    int mid = (r + l) / 2;
    int x = mid;
    bool fnd = false;
    for (int j = 1; j <= q; j++) {
      if (x == 0) {
        fnd = 1;
        break;
      }
      if (t[j] == s[x - 1]) {
        if (d[j] == 'L') {
          x--;
        } else {
          x++;
        }
      }
      if (x == n + 1) {
        break;
      }
    }
    if (x == 0) {
      fnd = 1;
    }
    if (fnd) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  int li = l;
  l = li;
  r = n + 1;
  while (r - l > 0) {
    int mid = (r + l) / 2 + 1;
    int x = mid;
    bool fnd = false;
    for (int j = 1; j <= q; j++) {
      if (x == n + 1) {
        fnd = 1;
        break;
      }
      if (t[j] == s[x - 1]) {
        if (d[j] == 'L') {
          x--;
        } else {
          x++;
        }
      }
      if (x == 0) {
        break;
      }
    }
    if (x == n + 1) {
      fnd = 1;
    }
    if (fnd) {
      r = mid - 1;
    } else {
      l = mid;
    }
  }
  int ri = l;
  cout << ri - li + 1 << "\n";
  return 0;
}
