#include <bits/stdc++.h>
using namespace std;
bool f(int m, string s, pair<char, char> a[], int q, int n) {
  char tar = s[m];
  int i = m;
  for (int j = 0; j < q; j++) {
    auto e = a[j];
    if (e.first == tar) {
      e.second == 'L' ? i-- : i++;
      if (i == -1) {
        return true;
      }
      tar = s[i];
    }
  }
  return false;
}
bool g(int m, string s, pair<char, char> a[], int q, int n) {
  char tar = s[m];
  int i = m;
  for (int j = 0; j < q; j++) {
    auto e = a[j];
    if (e.first == tar) {
      e.second == 'L' ? i-- : i++;
      if (i == n) {
        return true;
      }
      tar = s[i];
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, q;
  string s;
  pair<char, char> a[100000];
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) {
    cin >> a[i].first >> a[i].second;
  }
  int left = -1, right = n;
  int l = 0, r = n - 1;
  while (l <= r) {
    int m = (l + r) / 2;
    if (f(m, s, a, q, n)) {
      left = m;
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  l = 0, r = n - 1;
  while (l <= r) {
    int m = (l + r) / 2;
    if (g(m, s, a, q, n)) {
      right = m;
      r = m - 1;
    } else {
      l = m + 1;
    }
  }
  cout << max(0, right - left - 1);
}
