#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long n, q;
string s;
vector<pair<char, char>> v;
bool check(long long pos) {
  for (long long i = (0); i < (q); i++) {
    char c1 = v[i].first, c2 = v[i].second;
    if (c1 != s[pos]) continue;
    if (c2 == 'R')
      pos++;
    else
      pos--;
    if (pos == -1 || pos == n) return true;
  }
  return false;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q >> s;
  v.resize(q);
  for (long long i = (0); i < (q); i++) cin >> v[i].first >> v[i].second;
  long long l = 0, r = n;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  long long pos_l = l;
  l = 0, r = n;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  long long pos_r = l;
  cout << pos_r - pos_l << endl;
}
