#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX_N = 2 * 1e5 + 10;
int n, q;
string s;
char t[MAX_N], d[MAX_N];
bool Check(int idx) {
  if (idx < 0 || n <= idx) return false;
  for (int i = 0; i < q; ++i) {
    if (s[idx] == t[i]) {
      if (d[i] == 'L')
        --idx;
      else
        ++idx;
    }
    if (idx == -1 || idx == n) return true;
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q >> s;
  for (int i = 0; i < q; ++i) {
    cin >> t[i] >> d[i];
  }
  int left = -1, right = n;
  {
    int lb = -1, ub = n;
    while (1 < ub - lb) {
      int mid = (lb + ub) >> 1;
      if (Check(mid))
        lb = mid;
      else
        ub = mid;
    }
    left = lb;
  }
  {
    int lb = -1, ub = n;
    while (1 < ub - lb) {
      int mid = (lb + ub) >> 1;
      if (Check(mid))
        ub = mid;
      else
        lb = mid;
    }
    right = ub;
  }
  cout << n - (left + 1 + (n - right)) << endl;
  ;
  return 0;
}
