#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<int> line(N + 2, 1);
  for (int i = 0; i < Q; ++i) {
    char t, l;
    cin >> t >> l;
    for (int j = 0; j < s.size(); ++j) {
      if (s[j] == t) {
        if (l == 'L') {
          line[j] += line[j + 1];
          line[j + 1] = 0;
        } else {
          line[j + 2] += line[j + 1];
          line[j + 1] = 0;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i < s.size() + 1; ++i) {
    if (line[i]) {
      ans += line[i];
    }
  }
  cout << ans << endl;
}
