#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  s = " " + s + " ";
  vector<char> t(Q), d(Q);
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  int low = 0;
  int high = N + 1;
  while (high - low > 1) {
    int mid = (high + low) / 2;
    bool isin = true;
    int idx = mid;
    for (int i = 0; i < Q; i++) {
      if (t[i] == s[idx]) {
        if (d[i] == 'L')
          idx--;
        else
          idx++;
      }
      if (idx < 1 or N < idx) {
        isin = false;
        break;
      }
    }
    if (isin)
      high = mid;
    else
      low = mid;
  }
  int lans = high;
  low = 0;
  high = N + 1;
  while (high - low > 1) {
    int mid = (high + low) / 2;
    bool isin = true;
    int idx = mid;
    for (int i = 0; i < Q; i++) {
      if (t[i] == s[idx]) {
        if (d[i] == 'L')
          idx--;
        else
          idx++;
      }
      if (idx < 1 or N < idx) {
        isin = false;
        break;
      }
    }
    if (isin)
      low = mid;
    else
      high = mid;
  }
  int rans = low;
  cout << rans - lans + 1 << endl;
  return 0;
}
