#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll inf = numeric_limits<ll>::max() / 3;
const ll mod = 1e9 + 7;
int main(void) {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  map<char, set<int>> chache;
  map<int, int> now;
  for (int i = 0; i < n; ++i) {
    now[i + 1] = 1;
    chache[s[i]].insert(i + 1);
  }
  int res = 0;
  for (int i = 0; i < q; ++i) {
    char t, d;
    cin >> t >> d;
    map<int, int> next;
    for (auto p : now) {
      int idx = p.first;
      int num = p.second;
      if (chache[t].find(idx) == chache[t].end()) {
        next[idx] += num;
      } else {
        if (d == 'L') {
          if (idx == 1) {
            res += num;
          } else {
            next[idx - 1] += num;
          }
        } else {
          if (idx == n) {
            res += num;
          } else {
            next[idx + 1] += num;
          }
        }
      }
    }
    now = next;
  }
  cout << n - res << endl;
  return 0;
}
