#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
template <class T, class U>
using vp = vector<pair<T, U>>;
template <class T>
using vv = vector<vector<T>>;
template <class T, class U>
using vvp = vv<pair<T, U>>;
template <class T>
vv<T> vvec(const size_t n, const size_t m, const T v) {
  return vv<T>(n, vector<T>(m, v));
}
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;
}
constexpr long long pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28;
constexpr long long LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5;
constexpr int MOD = 1e9 + 7;
constexpr double EPS = 1e-6;
constexpr int dy[4] = {0, 1, 0, -1};
constexpr int dx[4] = {1, 0, -1, 0};
struct aaa {
  aaa() {
    cin.tie(0);
    ios::sync_with_stdio(0);
  };
} aaaa;
int N, Q;
string S;
vector<char> T, D;
int main() {
  cin >> N >> Q >> S;
  T.resize(Q);
  D.resize(Q);
  for (int i = int(0), i_len = (Q); i < i_len; ++i) {
    cin >> T[i] >> D[i];
  }
  reverse(T.begin(), T.end());
  reverse(D.begin(), D.end());
  int l = 0;
  int r = N - 1;
  int lmax = l - 1;
  int rmin = r + 1;
  for (int i = int(0), i_len = (Q); i < i_len; ++i) {
    if (l < N - 1 && D[i] == 'L' && S[l] == T[i]) {
      l++;
      chmax(lmax, l - 1);
    } else if (0 < r && D[i] == 'R' && S[r] == T[i]) {
      r--;
      chmin(rmin, r + 1);
    }
    if (0 < l && D[i] == 'R' && S[l - 1] == T[i]) {
      l--;
    } else if (r < N - 1 && D[i] == 'L' && S[r + 1] == T[i]) {
      r++;
    }
  }
  cout << (max(0, r - l + 1)) << "\n";
}
