#include <bits/stdc++.h>
using namespace std;
int N, Q;
char s[200000], t[200000], d[200000];
int BS1(int min, int max) {
  if (max - min > 1) {
    int check = 0;
    int mid = min + (max - min) / 2;
    int tmp = mid;
    for (int i = 0; i < Q; i++) {
      if (s[tmp] == t[i]) {
        if (d[i] == 'L')
          tmp--;
        else
          tmp++;
      }
      if (tmp == -1) {
        check++;
        break;
      }
      if (tmp == N) {
        break;
      }
    }
    if (check == 0) {
      return BS1(min, mid);
    } else {
      return BS1(mid, max);
    }
  } else {
    int check = 0;
    int mid = min;
    int tmp = mid;
    for (int i = 0; i < Q; i++) {
      if (s[tmp] == t[i]) {
        if (d[i] == 'L')
          tmp--;
        else
          tmp++;
      }
      if (tmp == -1) {
        check++;
        break;
      }
      if (tmp == N) {
        break;
      }
    }
    if (check == 0) {
      return mid - 1;
    } else {
      return mid;
    }
  }
}
int BS2(int min, int max) {
  if (max - min > 1) {
    int check = 0;
    int mid = min + (max - min) / 2;
    int tmp = mid;
    for (int i = 0; i < Q; i++) {
      if (s[tmp] == t[i]) {
        if (d[i] == 'L')
          tmp--;
        else
          tmp++;
      }
      if (tmp == -1) {
        break;
      }
      if (tmp == N) {
        check++;
        break;
      }
    }
    if (check == 0) {
      return BS2(mid, max);
    } else {
      return BS2(min, mid);
    }
  } else {
    int check = 0;
    int mid = max;
    int tmp = mid;
    for (int i = 0; i < Q; i++) {
      if (s[tmp] == t[i]) {
        if (d[i] == 'L')
          tmp--;
        else
          tmp++;
      }
      if (tmp == -1) {
        break;
      }
      if (tmp == N) {
        check++;
        break;
      }
    }
    if (check == 0) {
      return mid + 1;
    } else {
      return mid;
    }
  }
}
int main() {
  cin >> N >> Q;
  for (int i = 0; i < N; i++) cin >> s[i];
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  int a = BS1(0, N - 1);
  int b = BS2(0, N - 1);
  cout << b - a - 1;
  return 0;
}
