#include <bits/stdc++.h>
void print() { std::cout << std::endl; }
template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
  std::cout << head << ",";
  print(std::forward<Tail>(tail)...);
}
using namespace std;
void solve0() {
  int64_t N, Q;
  scanf("%lld%lld", &N, &Q);
  vector<char> s(N);
  vector<pair<char, char>> td(Q);
  getc(stdin);
  for (int i = 0; i < N; i++) {
    s[i] = getc(stdin);
  }
  getc(stdin);
  for (int i = 0; i < Q; i++) {
    char t, d;
    scanf("%c %c\n", &t, &d);
    td[i] = make_pair(t, d);
  }
  int L = 0;
  for (int i = Q - 1; i >= 0; i--) {
    char t = td[i].first;
    char d = td[i].second;
    if (d == 'L') {
      L = L + (t == s[L]);
    } else if (L > 0) {
      L = L - (t == s[L - 1]);
    }
    if (L < 0) {
      L = 0;
    } else if (L >= N) {
      L = N - 1;
    }
  }
  int R = N - 1;
  for (int i = Q - 1; i >= 0; i--) {
    char t = td[i].first;
    char d = td[i].second;
    if (d == 'R') {
      R = R - (t == s[R]);
    } else if (R < N - 1) {
      R = R + (t == s[R + 1]);
    }
    if (R < 0) {
      R = 0;
    } else if (R >= N) {
      R = N - 1;
    }
  }
  cout << 0 << endl;
}
int main(int argc, char **argv) {
  solve0();
  return 0;
}
