#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, t;
char a[N];
pair<char, char> q[N];
bool check(int x, bool markLow) {
  for (int i = 1; i <= t; i++) {
    if (q[i].first == a[x]) {
      if (q[i].second == 'L') {
        x--;
      } else {
        x++;
      }
    }
    if (x <= 0) {
      return markLow;
    }
    if (x > n) {
      return !markLow;
    }
  }
  return false;
}
int main() {
  scanf("%d%d", &n, &t);
  for (int i = 1; i <= n; i++) {
    scanf(" %c", &a[i]);
  }
  for (int i = 1; i <= t; i++) {
    scanf(" %c %c", &q[i].first, &q[i].second);
  }
  int lo = 0, hi = n, least1 = 0, most1 = n + 1;
  while (lo < hi) {
    int mid = (lo + hi + 1) / 2;
    if (check(mid, true)) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  int least = lo;
  lo = 1, hi = n + 1;
  while (lo < hi) {
    int mid = (lo + hi + 1) / 2;
    if (check(mid, false)) {
      hi = mid - 1;
    } else {
      lo = mid;
    }
  }
  int most = lo + 1;
  printf("%d\n", min(n, max(0, most - least - 1)));
  return 0;
}
