#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q, ans = 0;
  char t, d;
  string s;
  cin >> n >> q;
  cin >> s;
  vector<int> pos(n + 2, 1);
  pos[n + 1] = 0;
  pos[0] = 0;
  vector<vector<int> > alb(26);
  for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i) {
    alb[*i - 'A'].push_back(i - s.begin() + 1);
  }
  for (int(i) = 0; (i) < (q); (i)++) {
    cin >> t >> d;
    vector<int> turn(n + 2, 0);
    vector<int> jst;
    for (typeof((alb[t - 'A']).begin()) j = (alb[t - 'A']).begin();
         j != (alb[t - 'A']).end(); ++j) {
      if (d == 'L') {
        turn[*j - 1] += pos[*j];
        jst.push_back(*j - 1);
      } else {
        turn[*j + 1] += pos[*j];
        jst.push_back(*j + 1);
      }
      pos[*j] = 0;
    }
    for (typeof((jst).begin()) j = (jst).begin(); j != (jst).end(); ++j) {
      pos[*j] += turn[*j];
    }
  }
  for (int(i) = 0; (i) < (n); (i)++) {
    ans += pos[i + 1];
  }
  cout << ans << endl;
  return 0;
}
