#include <bits/stdc++.h>
using namespace std;
void solve(long long N, long long Q, std::string s, std::vector<char> t,
           std::vector<char> d) {
  vector<long long> data(N, 1);
  for (long long i = 0; i < Q; ++i) {
    for (long long j = 0; j < N; ++j) {
      if (t[i] == s[j]) {
        if (d[i] == 'R') {
          if (j == N - 1) {
            if (data[j] > 0) data[j] = 0;
          } else {
            if (data[j] > 0) {
              data[j + 1] = data[j + 1] + data[j];
              data[j] = 0;
            }
          }
        } else if (d[i] == 'L') {
          if (j == 0) {
            if (data[j] > 0) data[j] = 0;
          } else {
            if (data[j] > 0) {
              data[j - 1] = data[j - 1] + data[j];
              data[j] = 0;
            }
          }
        }
      }
    }
  }
  cout << accumulate(data.begin(), data.end(), 0LL) << endl;
}
int main() {
  long long N;
  scanf("%lld", &N);
  long long Q;
  scanf("%lld", &Q);
  std::string s;
  std::cin >> s;
  std::vector<char> t(Q);
  std::vector<char> d(Q);
  for (int i = 0; i < Q; i++) {
    std::cin >> t[i];
    std::cin >> d[i];
  }
  solve(N, Q, s, std::move(t), std::move(d));
  return 0;
}
