#include <bits/stdc++.h>
using namespace std;
long long N;
long long Q;
int main() {
  multimap<string, long long> mp;
  multimap<string, long long> mp2;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<long long> memo(N, 1);
  for (long long i = 0; i < N; i++) {
    mp.insert(make_pair(s.substr(i, 1), i));
  }
  for (long long i = N - 1; i >= 0; i--) {
    mp2.insert(make_pair(s.substr(i, 1), i));
  }
  vector<string> T(Q);
  vector<string> D(Q);
  for (long long i = 0; i < Q; i++) {
    cin >> T[i] >> D[i];
  }
  string t, d;
  for (long long i = 0; i < Q; i++) {
    t = T[i];
    d = D[i];
    long long count = 0;
    long long count2 = 0;
    count = (int)mp.count(t);
    auto itr = mp.find(t);
    count2 = (int)mp2.count(t);
    auto itr2 = mp2.find(t);
    if (d == "L") {
      for (long long j = 0; j < count; j++) {
        long long posi = itr->second;
        if (posi == 0) {
          memo[posi] = 0;
          itr++;
          continue;
        }
        memo[posi - 1] += memo[posi];
        memo[posi] = 0;
        itr++;
      }
    } else {
      for (long long j = 0; j < count2; j++) {
        long long posi = itr2->second;
        if (posi == N - 1) {
          memo[posi] = 0;
          itr2++;
          continue;
        }
        memo[posi + 1] += memo[posi];
        memo[posi] = 0;
        itr2++;
      }
    }
  }
  long long ans = 0;
  for (int k = 0; k < N; k++) {
    ans += memo[k];
  }
  cout << ans << endl;
}
