#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 9;
int n, q;
string s;
pair<char, char> query[maxn];
int fall(int pos) {
  for (int i = 0; i < q; i++) {
    if (query[i].first == s[pos]) {
      pos += (query[i].second == 'L' ? -1 : 1);
    }
    if (pos < 0) {
      return 1;
    } else if (pos >= n) {
      return 3;
    }
  }
  return 2;
}
int lower_bound(int x) {
  int start = 0, end = n - 1;
  while (end > start) {
    int mid = (start + end) / 2;
    if (fall(mid) >= x) {
      end = mid;
    } else {
      start = mid + 1;
    }
  }
  return end;
}
int upper_bound(int x) {
  int start = 0, end = n - 1;
  while (end > start) {
    int mid = (start + end) / 2;
    if (fall(mid) > x) {
      end = mid;
    } else {
      start = mid + 1;
    }
  }
  return end;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) {
    cin >> query[i].first >> query[i].second;
  }
  int pos1 = upper_bound(1) - 1, pos2 = lower_bound(3);
  int ans = 0;
  if (fall(pos1) == 1) {
    ans += (pos1 + 1);
  }
  if (fall(pos2) == 3) {
    ans += (n - pos2);
  }
  cout << n - ans << '\n';
  return 0;
}
