#include <bits/stdc++.h>
using namespace std;
static const long long INF = INT64_MAX;
static const long long MOD = (long long)1e9 + 7;
template <typename T>
void debug(T t) {
  cerr << t << "\n";
}
template <typename T, typename... Args>
void debug(T t, Args... args) {
  cerr << t << " ";
  debug(args...);
}
template <typename T>
void out(T t) {
  cout << t << "\n";
}
template <typename T, typename... Args>
void out(T t, Args... args) {
  cout << t << " ";
  out(args...);
}
long long is_alive(long long x, long long N, string s, string &t, string &d) {
  for (long long i = 0; i < N; i++) {
    if (s[x] == t[i]) {
      if (d[i] == 'L') x--;
      if (d[i] == 'R') x++;
    }
    if (x == -1) return -1;
    if (x == N) return 1;
  }
  return 0;
}
void solve() {
  long long N, Q;
  string s;
  cin >> N >> Q;
  string T, D;
  T.resize(Q);
  D.resize(Q);
  cin >> s;
  debug(s);
  for (int f = 0; f < Q; f++) {
    char a, b;
    cin >> a >> b;
    T[f] = a;
    D[f] = b;
  }
  long long lb = 0, ub = N;
  while (ub - lb > 1) {
    long long md = (lb + ub) / 2;
    if (is_alive(md, N, s, T, D) == -1) {
      lb = md;
    } else {
      ub = md;
    }
  }
  long long ans1 = ub;
  lb = 0, ub = N;
  while (ub - lb > 1) {
    long long md = (lb + ub) / 2;
    if (is_alive(md, N, s, T, D) != 1) {
      lb = md;
    } else {
      ub = md;
    }
  }
  long long ans2 = ub;
  out(ans2 - ans1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
