#include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
char t[100000], d[100000];
bool Right(int m) {
  for (int(i) = 0; (i) < (q); (i)++) {
    if (s[m] == t[i]) {
      if (d[i] == 'R') {
        m++;
      } else {
        m--;
      }
      if (m == n) {
        return true;
      }
    }
  }
  return false;
}
bool Left(int m) {
  for (int(i) = 0; (i) < (q); (i)++) {
    if (s[m] == t[i]) {
      if (d[i] == 'R') {
        m++;
      } else {
        m--;
      }
      if (m < 0) {
        return true;
      }
    }
  }
  return false;
}
int main() {
  cin >> n >> q >> s;
  for (int(i) = 0; (i) < (q); (i)++) {
    cin >> t[i] >> d[i];
  }
  int l = -1, r = n;
  while (r - l > 1) {
    int m = (r - l) / 2;
    if (Right(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  int ans = r - 1;
  l = 0, r = n + 1;
  while (r - l > 1) {
    int m = (r - l) / 2;
    if (Left(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  ans -= l;
  cout << ans << endl;
  return 0;
}
