#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s, t, d, s2;
  cin >> n >> q >> s;
  vector<int> v(n + 2, 1);
  for (int val1 = 0; val1 < q; val1++) {
    cin >> t >> d;
    for (int val2 = 0; val2 < n; val2++) {
      s2 = s[val2];
      if (s2 == t) {
        if (d == "R") {
          int before = v[val2 + 1];
          v[val2 + 1] = 0;
          v[val2 + 2] += before;
        } else {
          int before = v[val2 + 1];
          v[val2 + 1] = 0;
          v[val2] += before;
        }
      }
    }
  }
  cout << accumulate(v.begin() + 1, v.end() - 1, 0) << endl;
}
