#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<char> t(Q);
  vector<char> d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> t.at(i) >> d.at(i);
  }
  int left = -1, right = N, mid;
  for (int k = 0; k < 20; k++) {
    mid = (left + right) / 2;
    int mid_now = mid;
    bool l = 0;
    for (int i = 0; i < Q; i++) {
      if (0 <= mid_now && mid_now < N && S.at(mid_now) == t.at(i)) {
        if (d.at(i) == 'L') {
          mid_now--;
        } else {
          mid_now++;
        }
      }
      if (mid_now >= N) {
        l = 1;
      }
    }
    if (l == 1) {
      right = mid;
      break;
    } else {
      left = mid;
    }
  }
  int left_2 = -1, right_2 = N, mid_2;
  for (int k = 0; k < 20; k++) {
    mid_2 = (left_2 + right_2) / 2;
    int mid_now_2 = mid_2;
    bool l = 0;
    for (int i = 0; i < Q; i++) {
      if (0 <= mid_now_2 && mid_now_2 < N && S.at(mid_now_2) == t.at(i)) {
        if (d.at(i) == 'L') {
          mid_now_2--;
        } else {
          mid_now_2++;
        }
      }
      if (mid_now_2 < 0) {
        l = 1;
        break;
      }
    }
    if (l == 1) {
      left_2 = mid_2;
    } else {
      right_2 = mid_2;
    }
  }
  cout << min(0, right - right_2) << endl;
}
