#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  int LR[N + 2];
  char S[N + 1];
  for (int i = 1; i <= N; ++i) cin >> S[i];
  for (int i = 0; i <= N + 1; ++i) LR[i] = 1;
  for (int i = 1; i <= Q; ++i) {
    char A, B;
    cin >> A >> B;
    for (int j = 1; j <= N; ++j) {
      if (A == S[i] && LR[i] > 0) {
        LR[i] -= 1;
        if (B == 'L')
          LR[i - 1] += 1;
        else
          LR[i + 1] += 1;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; ++i) ans += LR[i];
  cout << ans << endl;
}
