#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1e18;
signed main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[n], d[n];
  for (long long i = (0); i < (q); ++i) cin >> t[i] >> d[i];
  long long ok = n;
  long long ng = -1;
  long long mid;
  while (ok - ng > 1) {
    mid = (ok + ng) / 2;
    long long loc = mid;
    bool flg = false;
    for (long long i = (0); i < (q); ++i) {
      if (t[i] == s[loc]) {
        if (d[i] == 'R')
          loc++;
        else
          loc--;
        if (loc == n) {
          flg = true;
          break;
        }
        if (loc == -1) break;
      }
    }
    if (flg)
      ok = mid;
    else
      ng = mid;
  }
  long long ok2 = -1;
  long long ng2 = n;
  long long mid2;
  while (ng2 - ok2 > 1) {
    mid2 = (ok2 + ng2) / 2;
    long long loc = mid2;
    bool flg = false;
    for (long long i = (0); i < (q); ++i) {
      if (t[i] == s[loc]) {
        if (d[i] == 'R')
          loc++;
        else
          loc--;
        if (loc == n) break;
        if (loc == -1) {
          flg = true;
          break;
        }
      }
    }
    if (flg)
      ok2 = mid2;
    else
      ng2 = mid2;
  }
  cout << max(n - (n - ok) - (ok2 + 1), 0ll) << endl;
}
