#include <bits/stdc++.h>
using namespace std;
const long long LLINF = (1LL << 60);
const long long INF = (1LL << 30);
const double DINF = std::numeric_limits<double>::infinity();
const long long MOD = 1000000007;
long long N, Q;
string S;
vector<char> T;
vector<char> D;
static inline bool check_l(long long ind) {
  long long cur = ind;
  for (long long i = 0; i < Q; ++i) {
    if (T[i] == S[ind]) {
      if (D[i] == 'L') {
        ind--;
        if (ind < 0) {
          return true;
        }
      } else {
        ind++;
      }
    }
  }
  return false;
}
static inline bool check_r(long long ind) {
  long long cur = ind;
  for (long long i = 0; i < Q; ++i) {
    if (T[i] == S[ind]) {
      if (D[i] == 'L') {
        ind--;
      } else {
        ind++;
        if (ind >= N) {
          return true;
        }
      }
    }
  }
  return false;
}
long long solve() {
  long long del_l = -1;
  long long lb = 0, rb = N - 1;
  while (rb - lb > 1) {
    long long mid = (lb + rb) / 2;
    if (check_l(mid)) {
      lb = mid;
    } else {
      rb = mid;
    }
  }
  if (check_l(rb)) {
    del_l = rb;
  } else if (check_l(lb)) {
    del_l = lb;
  }
  long long del_r = -1;
  lb = 0;
  rb = N - 1;
  while (rb - lb > 1) {
    long long mid = (lb + rb) / 2;
    bool ret = check_r(mid);
    if (ret) {
      rb = mid;
    } else {
      lb = mid;
    }
  }
  if (check_r(lb)) {
    del_r = rb;
  } else if (check_r(rb)) {
    del_r = lb;
  }
  if (del_l == -1) {
    if (del_r == -1) {
      return N;
    }
    return del_r;
  }
  if (del_r == -1) {
    return N - (del_l + 1);
  }
  if (del_l >= del_r) {
    return 0;
  }
  return N - (del_l + 1) - (N - del_r);
}
signed main() {
  cin >> N >> Q >> S;
  T.resize(Q);
  D.resize(Q);
  for (long long i = 0; i < Q; ++i) {
    cin >> T[i] >> D[i];
  }
  long long ans = solve();
  printf("%lld\n", ans);
  return 0;
}
