#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<vector<long long> > PosMap(28);
  for (long long i = 0; i < n; i++) {
    PosMap[s[i] - 'A'].push_back(i);
  }
  vector<long long> countings(n, 1);
  long long rT = n;
  for (long long i = 0; i < m; i++) {
    char a, b;
    cin >> a >> b;
    vector<long long> in;
    for (long long j = 0; j < PosMap[a - 'A'].size(); j++) {
      in.push_back(countings[PosMap[a - 'A'][j]]);
      countings[PosMap[a - 'A'][j]] = 0;
    }
    for (long long j = 0; j < PosMap[a - 'A'].size(); j++) {
      if (b == 'L') {
        if (PosMap[a - 'A'][j] == 0) {
          rT -= in[j];
        } else {
          countings[PosMap[a - 'A'][j] - 1] += in[j];
        }
      } else {
        if (PosMap[a - 'A'][j] == n - 1) {
          rT -= in[j];
        } else {
          countings[PosMap[a - 'A'][j] + 1] += in[j];
        }
      }
    }
  }
  cout << rT << "\n";
}
