#include <bits/stdc++.h>
using namespace std;
void move(vector<long>& gn, string s, char t, char d) {
  vector<long> temp = gn;
  for (long i = 0; i < gn.size(); ++i) {
    if (i == 0 and s[0] == t and d == 'L') {
      temp[0] = 0;
    } else if (i == gn.size() - 1 and s[i] == t and d == 'R') {
      temp[i] = 0;
    } else if (s[i] == t) {
      if (d == 'L') {
        temp[i - 1] += gn[i];
        temp[i] -= gn[i];
      } else {
        temp[i + 1] += gn[i];
        temp[i] -= gn[i];
      }
    }
  }
  gn = temp;
}
int main() {
  long n, q;
  cin >> n >> q;
  string s;
  vector<char> t(q), d(q);
  cin >> s;
  for (long i = 0; i < q; ++i) {
    cin >> t[i] >> d[i];
  }
  vector<long> gn(n, 1);
  for (long i = 0; i < q; ++i) {
    move(gn, s, t[i], d[i]);
  }
  long sum = accumulate(gn.begin(), gn.end(), 0);
  cout << sum << endl;
  return 0;
}
