#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  int cup[N];
  for (int i = 0; i < N; i++) {
    cup[i] = 1;
  }
  string t, d;
  for (int i = 0; i < Q; i++) {
    cin >> t >> d;
    for (int j = 0; j < N; j++) {
      if (t[0] == s[j]) {
        if (d == "L") {
          if (j == 0) {
            cup[j] = 0;
          } else {
            cup[j - 1] = cup[j - 1] + cup[j];
            cup[j] = 0;
          }
        } else {
          if (j == N - 1) {
            cup[j] = 0;
          } else {
            cup[j + 1] = cup[j + 1] + cup[j];
            cup[j] = 0;
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = ans + cup[i];
  }
  cout << ans << endl;
}
