#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const long long INF = 100000000;
const long long MOD = 1000000007;
int n, q;
string s;
char t[200000], d[100000];
int main() {
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  int le, ri;
  {
    int st = -1, en = n, mid;
    while (en - st > 1) {
      mid = (st + en) / 2;
      int pos = mid;
      bool ok = false;
      for (int i = 0; i < q; i++) {
        if (t[i] == s[pos]) {
          if (d[i] == 'R') {
            pos++;
          } else {
            pos--;
          }
          if (pos < 0) {
            ok = true;
            break;
          }
          if (pos >= n) {
            ok = false;
            break;
          }
        }
      }
      if (ok)
        st = mid;
      else
        en = mid;
    }
    le = st;
  }
  {
    int st = -1, en = n, mid;
    while (en - st > 1) {
      mid = (st + en) / 2;
      int pos = mid;
      bool ok = false;
      for (int i = 0; i < q; i++) {
        if (t[i] == s[pos]) {
          if (d[i] == 'R') {
            pos++;
          } else {
            pos--;
          }
          if (pos < 0) {
            ok = false;
            break;
          }
          if (pos >= n) {
            ok = true;
            break;
          }
        }
      }
      if (ok)
        en = mid;
      else
        st = mid;
    }
    ri = en;
  }
  cout << ri - le - 1 << endl;
}
