#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<int> cell(N, 1);
  for (int i = 0; i < Q; ++i) {
    char t, d;
    cin >> t >> d;
    for (int j = 0; j < N; ++j) {
      int k = (d == 'L') ? j : N - j - 1;
      int l = (d == 'L') ? k - 1 : k + 1;
      if (s[k] == t) {
        if (0 <= l && l < N) cell[l] += cell[k];
        cell[k] = 0;
      }
    }
  }
  int sum = 0;
  for (int e : cell) sum += e;
  cout << sum << endl;
}
