#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool CHMIN(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool CHMAX(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline void SORT(T& a) {
  sort(a.begin(), a.end());
}
template <class T>
inline void REV(T& a) {
  reverse(a.begin(), a.end());
}
template <class T>
inline void UNI(T& a) {
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
}
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")";
  return os;
}
const long long MOD = 1000000007;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
long long N, Q;
string S;
char t[200010], d[200010];
bool check(string s, long long x, long long b) {
  for (long long i = (0); i < (Q); ++i) {
    if (t[i] == s[x]) {
      if (b > 0) {
        if (d[i] == 'L')
          x--;
        else
          x++;
      } else {
        if (d[i] == 'L')
          x++;
        else
          x--;
      }
      if (x < 0 || x >= N) return true;
    }
  }
  return false;
}
long long calc(string s, long long b) {
  long long ok = -1, ng = N;
  while (ng - ok > 1) {
    long long m = (ok + ng) / 2;
    if (check(s, m, b))
      ok = m;
    else
      ng = m;
  }
  return ng;
}
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> N >> Q >> S;
  for (long long i = (0); i < (Q); ++i) cin >> t[i] >> d[i];
  long long L = calc(S, 1);
  reverse(((S).begin()), ((S).end()));
  long long R = calc(S, -1);
  cout << N - L - R << endl;
  return 0;
}
