#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<pair<char, char>> pll(n);
  for (int i = 0; i < q; i++) {
    cin >> pll[i].first >> pll[i].second;
  }
  long long right;
  bool flfl = false;
  long long le = -1, ri = n;
  while (ri - le > 1) {
    long long mid = (le + ri) / 2;
    long long now = mid;
    if (now >= n || now < 0) {
      flfl = true;
      break;
    }
    bool can = false;
    for (int i = 0; i < q; i++) {
      if (s[now] == pll[i].first) {
        if (pll[i].second == 'R')
          now++;
        else
          now--;
      }
      if (now < 0) break;
      if (now == n) {
        can = true;
        break;
      }
    }
    if (can) {
      ri = mid;
    } else {
      le = mid;
    }
  }
  if (flfl) {
    right = n;
  } else
    right = ri;
  long long left;
  flfl = false;
  le = -1;
  ri = n;
  while (ri - le > 1) {
    long long mid = (le + ri) / 2;
    long long now = mid;
    if (now >= n || now < 0) {
      flfl = true;
      break;
    }
    bool can = false;
    for (int i = 0; i < q; i++) {
      if (s[now] == pll[i].first) {
        if (pll[i].second == 'R')
          now++;
        else
          now--;
      }
      if (now >= n) break;
      if (now == -1) {
        can = true;
        break;
      }
    }
    if (can) {
      le = mid;
    } else {
      ri = mid;
    }
  }
  if (flfl)
    left = -1;
  else
    left = le;
  if (left == -1 && right == n) {
    cout << n << endl;
  } else if (left == -1) {
    cout << n - (n - right) << endl;
  } else if (right == n) {
    cout << (n - (left + 1)) << endl;
  } else {
    long long ans = (left + 1 + (n - right)) - max(0LL, left - right + 1);
    cout << n - ans << endl;
  }
  return 0;
}
