#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmax(T &a, T b) {
  a = max(a, b);
}
template <typename T>
void chmin(T &a, T b) {
  a = min(a, b);
}
template <typename T>
void chadd(T &a, T b) {
  a = a + b;
}
long long int dx[] = {0, 0, 1, -1};
long long int dy[] = {1, -1, 0, 0};
const long long INF = 1001001001001001LL;
const long long MOD = 1000000007LL;
long long int N, Q;
string s;
char t[200010], d[200010];
long long int get_state(long long int x) {
  for (long long int i = 0; i < Q; i++) {
    if (s[x] == t[i]) {
      if (d[i] == 'L') x--;
      if (d[i] == 'R') x++;
    }
    if (x < 0) return 1;
    if (x >= N) return 2;
  }
  return 0;
}
long long int bs1() {
  long long int ub = N + 1, lb = 0;
  while (ub - lb > 1) {
    long long int mid = (ub + lb) / 2;
    if (get_state(mid) == 1)
      lb = mid;
    else
      ub = mid;
  }
  return lb;
}
long long int bs2() {
  long long int ub = N, lb = -1;
  while (ub - lb > 1) {
    long long int mid = (ub + lb) / 2;
    if (get_state(mid) == 2)
      ub = mid;
    else
      lb = mid;
  }
  return ub;
}
signed main() {
  cin >> N >> Q;
  cin >> s;
  for (long long int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  long long int s1 = bs1() + 1;
  long long int s2 = bs2();
  long long int ans = N - s1 - (N - s2);
  cout << ans << endl;
  return 0;
}
