#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  char s[200010];
  for (int i = 0; i < n; i++) cin >> s[i];
  char t[200010], d[200010];
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  vector<int> map(200010);
  fill(map.begin(), map.end(), 1);
  for (int j = 0; j < q; j++) {
    for (int i = 0; i < n; i++) {
      if (s[i] == t[j]) {
        if (d[j] == 'L') {
          if (map[i] > 0) {
            if (i != 0) {
              map[i - 1] += map[i];
              map[i] = 0;
            } else {
              map[i] = 0;
            }
          }
        }
        if (d[j] == 'R') {
          if (map[i] > 0) {
            if (i != n - 1) {
              map[i + 1] += map[i];
              map[i] = 0;
            } else {
              map[i] = 0;
            }
          }
        }
      }
    }
  }
  int count = 0;
  for (int i = 0; i < n; i++) count += map[i];
  cout << count << endl;
}
