#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  vector<int> nums(n, 1);
  unordered_map<char, vector<int>> map_vec;
  for (int i = 0; i < n; ++i) {
    char c = s[i];
    map_vec[c].push_back(i);
  }
  int ans = 0;
  for (int i = 0; i < q; ++i) {
    char t, d;
    cin >> t >> d;
    if (map_vec.count(t) == 0) {
      continue;
    }
    int cnt = (d == 'L') ? -1 : 1;
    for (int id : map_vec[t]) {
      if (id + cnt < 0 || id + cnt >= n) {
        nums[id] = 0;
      } else {
        nums[id + cnt] += nums[id];
        nums[id] = 0;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    ans += nums[i];
  }
  cout << ans;
  return 0;
}
