#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <class T>
using V = vector<T>;
using Graph = vector<vector<int>>;
using P = pair<long long, long long>;
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;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, Q;
  cin >> n >> Q;
  string s;
  cin >> s;
  V<char> t(Q), d(Q);
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  int rans = 0;
  int left = -1, right = n - 1;
  while (right - left > 1) {
    int mid = (right + left) / 2;
    bool ok = 0;
    int k = mid;
    for (int i = 0; i < Q; i++) {
      if (s[k] == t[i]) {
        if (d[i] == 'L')
          k--;
        else
          k++;
        if (k == -1) {
          ok = 1;
          break;
        }
      }
    }
    if (ok)
      left = mid;
    else
      right = mid;
  }
  rans += right;
  left = 0, right = n;
  while (right - left > 1) {
    int mid = (right + left) / 2;
    bool ok = 0;
    int k = mid;
    for (int i = 0; i < Q; i++) {
      if (s[k] == t[i]) {
        if (d[i] == 'L')
          k--;
        else
          k++;
        if (k == n) {
          ok = 1;
          break;
        }
      }
    }
    if (ok)
      right = mid;
    else
      left = mid;
  }
  rans += n - left;
  cout << n - rans + 1 << endl;
}
