#include <bits/stdc++.h>
using namespace std;
long long n, q;
string str;
vector<pair<char, char>> v;
int syumi(int s) {
  for (long long(i) = (0); (i) < (q); ++i) {
    if (v[i].first == str[s]) {
      if (v[i].second == 'L')
        s--;
      else
        s++;
    }
    if (s < 0) return -1;
    if (s >= n) return 1;
  }
  return 0;
}
int seica_l() {
  int l = -1;
  int r = n - 1;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (syumi(mid) != -1)
      r = mid;
    else
      l = mid;
  }
  return r;
}
int seica_r() {
  int l = 0;
  int r = n;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (syumi(mid) != 1)
      l = mid;
    else
      r = mid;
  }
  return l;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  cin >> str;
  for (long long(i) = (0); (i) < (q); ++i) {
    char a, b;
    cin >> a >> b;
    v.emplace_back(a, b);
  }
  int l = seica_l();
  int r = seica_r();
  cout << max(0, r - l + 1) << endl;
  return 0;
}
