#include <bits/stdc++.h>
using namespace std;
int N, Q;
string S;
long long ans = 0;
string L = "L";
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> Q >> S;
  vector<int> P(N, 1);
  vector<vector<int>> ABC(100);
  for (int i = (0); i < (N); ++i) {
    ABC[S[i] - 'A'].push_back(i);
  }
  for (int i = (0); i < (Q); ++i) {
    string t, d;
    cin >> t >> d;
    for (int j = (0); j < (ABC[t[0] - 'A'].size()); ++j) {
      if ((ABC[t[0] - 'A'][j] == 0 && d == L) ||
          (ABC[t[0] - 'A'][j] == N - 1 && d != L)) {
        P[ABC[t[0] - 'A'][j]] = 0;
      } else {
        if (d == L) {
          P[ABC[t[0] - 'A'][j] - 1] += P[ABC[t[0] - 'A'][j]];
          P[ABC[t[0] - 'A'][j]] = 0;
        } else {
          P[ABC[t[0] - 'A'][j] + 1] += P[ABC[t[0] - 'A'][j]];
          P[ABC[t[0] - 'A'][j]] = 0;
        }
      }
    }
  }
  for (int i = (0); i < (N); ++i) {
    ans += P[i];
  }
  cout << ans << endl;
}
