#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, Q;
string s;
char A, L;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> Q;
  cin >> s;
  auto G = new int[N];
  for (int n = 0, n_len = (N); n < n_len; ++n) {
    G[n] = 1;
  }
  int sum = N;
  for (int q = 0, q_len = (Q); q < q_len; ++q) {
    cin >> A >> L;
    for (int n = 0, n_len = (N); n < n_len; ++n) {
      if (A == s[n]) {
        if (0 == n && L == 'L') {
          sum -= G[n];
          G[n] = 0;
        } else if (N - 1 == n && L == 'R') {
          sum -= G[n];
          G[n] = 0;
        } else if (L == 'L') {
          G[n - 1] += G[n];
          G[n] = 0;
        } else {
          G[n + 1] += G[n];
          G[n] = 0;
        }
      }
    }
  }
  cout << sum << endl;
  return 0;
}
