#include <bits/stdc++.h>
using namespace std;
string s;
int n, q;
char a[100010], b[100010];
bool binarySearch(int mid, int forward) {
  if (mid > n - 1 || mid < 0) {
    return 1;
  }
  int cur = mid;
  int ind = 0;
  for (int i = 1; i <= q; i++) {
    if (s[cur] == a[i]) {
      if (b[i] == 'L') {
        cur--;
      } else {
        cur++;
      }
    }
    if ((cur == n && !forward) || (cur == -1 && forward)) {
      break;
    }
  }
  if (cur == -1 && forward) {
    return 1;
  } else if (cur == n && !forward) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  cin >> n >> q;
  cin >> s;
  for (int i = 1; i <= q; i++) {
    cin >> a[i] >> b[i];
  }
  int low = -1, high = n, mid;
  int forwardAns = -1;
  while (high - low > 1) {
    mid = (low + high) / 2;
    if (binarySearch(mid, 1)) {
      low = mid;
      forwardAns = mid;
    } else {
      high = mid;
    }
  }
  low = -1, high = n;
  int backwardAns = n;
  while (high - low > 1) {
    mid = (low + high) / 2;
    if (binarySearch(mid, 0)) {
      high = mid;
      backwardAns = mid;
    } else {
      low = mid;
    }
  }
  if (backwardAns <= forwardAns) {
    cout << n << endl;
  } else {
    cout << backwardAns - forwardAns - 1 << endl;
  }
  return 0;
}
