#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  vector<char> m(N);
  for (int i = 0; i < N; i++) {
    cin >> m.at(i);
  }
  vector<char> T(Q), D(Q);
  for (int i = 0; i < Q; i++) {
    cin >> T.at(i) >> D.at(i);
  }
  int ok_L = N - 1, drop_L = 0, drop_R = N - 1, ok_R = 0;
  bool f_L, f_R;
  int pt;
  int init = 0;
  for (;;) {
    pt = init;
    f_L = false;
    f_R = false;
    for (int j = 0; j < Q; j++) {
      if (T.at(j) == m.at(pt)) {
        if (D.at(j) == 'L') {
          pt--;
        } else {
          pt++;
        }
        if (pt < 0) {
          f_L = true;
          drop_L = init;
          break;
        } else if (pt >= N) {
          f_R = true;
          break;
          drop_R = init;
        }
      }
    }
    if (f_L) {
      if (init == N - 1) {
        ok_L = N;
        drop_L = N - 1;
      } else {
        int n = (ok_L - init) / 2;
        n = (n == 0) ? 1 : n;
        init = init + n;
      }
    } else {
      ok_L = init;
      if (init == 0) {
        ok_L = 0;
        drop_L = -1;
      } else {
        int n = (init - drop_L) / 2;
        n = (n == 0) ? 1 : n;
        init = init - n;
      }
    }
    if (ok_L - drop_L == 1) {
      break;
    }
  }
  init = N - 1;
  for (;;) {
    pt = init;
    f_L = false;
    f_R = false;
    for (int j = 0; j < Q; j++) {
      if (T.at(j) == m.at(pt)) {
        if (D.at(j) == 'L') {
          pt--;
        } else {
          pt++;
        }
        if (pt < 0) {
          f_L = true;
          drop_L = init;
          break;
        } else if (pt >= N) {
          f_R = true;
          drop_R = init;
          break;
        }
      }
    }
    if (f_R) {
      if (init == 0) {
        ok_R = -1;
        drop_R = 0;
      } else {
        int n = (init - ok_R) / 2;
        n = (n == 0) ? 1 : n;
        init = init - n;
      }
    } else {
      ok_R = init;
      if (init == N - 1) {
        ok_R = N - 1;
        drop_R = N;
      } else {
        int n = (drop_R - init) / 2;
        n = (n == 0) ? 1 : n;
        init = init + n;
      }
    }
    if (drop_R - ok_R == 1) {
      break;
    }
  }
  cout << (ok_R - ok_L + 1) << endl;
}
