#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const unsigned long long BS1 = 10000019ULL;
const int INF = (1 << 29);
template <class T>
inline void fastScan(T &x) {
  register char c = getchar();
  int neg = 0;
  x = 0;
  for (; (c < 48 || c > 57) && (c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
int n, Q;
char s[N + N];
char t[N + N][2];
char d[N + N][2];
bool isLeftOk(int pos) {
  for (int i = 0; i < Q; i++) {
    if (s[pos] == t[i][0]) {
      if (d[i][0] == 'L') {
        pos--;
      } else {
        pos++;
      }
      if (pos < 0) {
        return 0;
      } else if (pos >= n) {
        return 2;
      }
    }
  }
  if (pos < 0) {
    return 0;
  } else if (pos >= n) {
    return 2;
  }
  return 1;
}
bool isRightOk(int pos) {
  for (int i = 0; i < Q; i++) {
    if (s[pos] == t[i][0]) {
      if (d[i][0] == 'L') {
        pos--;
      } else {
        pos++;
      }
      if (pos >= n) {
        return 0;
      } else if (pos < 0) {
        return 2;
      }
    }
  }
  if (pos >= n) {
    return 0;
  } else if (pos < 0) {
    return 2;
  }
  return 1;
}
int main() {
  fastScan(n);
  fastScan(Q);
  scanf("%s", s);
  for (int i = 0; i < Q; i++) {
    scanf("%s %s", t[i], d[i]);
  }
  int low = 0, high = n - 1, lft = 0;
  while (low <= high) {
    int mid = (low + high) >> 1;
    if (isLeftOk(mid) == 0) {
      low = mid + 1;
    } else {
      high = mid - 1;
      lft = mid;
    }
  }
  cerr << lft << '\n';
  low = 0;
  high = n - 1;
  int rgt = n - 1;
  while (low <= high) {
    int mid = (low + high) >> 1;
    if (isRightOk(mid) == 0) {
      high = mid - 1;
    } else {
      low = mid + 1;
      rgt = mid;
    }
  }
  cerr << rgt << '\n';
  int ans = (lft <= rgt) ? (rgt - lft + 1) : 0;
  printf("%d\n", ans);
}
