#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int ddy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int inf = 99999999;
const long long linf = 1LL << 62;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (a % b != 0) gcd(b, a % b);
  return b;
}
long long lcm(long long a, long long b) {
  if (a < b) swap(a, b);
  return (a / gcd(a, b)) * b;
}
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> v(n, 1);
  vector<vector<int> > pos;
  pos.resize(n);
  for (int i = 0; i < s.length(); i++) pos[s[i] - 'A'].push_back(i);
  for (int i = 0; i < q; i++) {
    char c, d;
    cin >> c >> d;
    int abc = c - 'A';
    if (d == 'L') {
      for (int j = 0; j < pos[abc].size(); j++) {
        if (pos[abc][j] - 1 >= 0) v[pos[abc][j] - 1] += v[pos[abc][j]];
        v[pos[abc][j]] = 0;
      }
    } else {
      for (int j = pos[abc].size() - 1; j >= 0; j--) {
        if (pos[abc][j] + 1 < n) v[pos[abc][j] + 1] += v[pos[abc][j]];
        v[pos[abc][j]] = 0;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) ans += v[i];
  cout << ans << endl;
  return 0;
}
