#include <bits/stdc++.h>
int main() {
  int N, Q;
  std::string S;
  std::cin >> N >> Q;
  std::cin >> S;
  using P = std::pair<char, char>;
  P temp, td[(2 * 100000)];
  for (int i = 0; i < Q; ++i) {
    std::cin >> temp.first >> temp.second;
    td[i] = temp;
  }
  int lcur = -1;
  int rcur = N;
  for (int i = Q - 1; i >= 0; --i) {
    if (S[lcur + 1] == td[i].first && td[i].second == 'L') {
      lcur++;
    } else if (S[lcur - 1] == td[i].first && td[i].second == 'R' &&
               lcur != -1) {
      lcur--;
    } else if (S[rcur - 1] == td[i].first && td[i].second == 'R') {
      rcur--;
    } else if (S[rcur + 1] == td[i].first && td[i].second == 'L' && rcur != N) {
      rcur++;
    }
  }
  int ans = N;
  if (lcur >= 0) ans -= lcur + 1;
  if (rcur <= N - 1) ans -= (N - 1) - rcur + 1;
  std::cout << ans << std::endl;
}
