#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N, Q; std::cin >> N >> Q;
  std::string S; std::cin >> S;

  std::string ts, ds;
  for (int i = 0; i < Q; ++i) {
    char t, d; std::cin >> t >> d;
    ts += t; ds += d;
  }

  int l = 0, r = N - 1;
  for (int i = Q - 1; i >= 0; --i) {
    if (ds[i] == 'L') {
      if (ts[i] == S[l]) ++l;
      if (r < N - 1 && ts[i] == S[r+1]) ++r;
    } else {
      if (l > 0 && ts[i] == S[l-1]) --l;
      if (ts[i] == S[r]) --r;
    }
  }

  std::cout << std::max(0, r - l + 1) << std::endl;
}
