#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string s;
  cin >> N >> Q >> s;
  vector<vector<char>> td(Q, vector<char>(2));
  for (int i = 0; i < Q; i++) {
    cin >> td[i][0] >> td[i][1];
  }
  vector<int> mas(N, 1);
  for (int i = 0; i < Q; i++) {
    for (int j = 0; j < N; j++) {
      if (s[j] == td[i][0]) {
        if (td[i][1] == 'R') {
          if (j == N - 1) {
            mas[j] = 0;
          } else {
            mas[j + 1] += mas[j];
            mas[j] = 0;
          }
        } else if (td[i][1] == 'L') {
          if (j == 0) {
            mas[j] = 0;
          } else {
            mas[j - 1] += mas[j];
            mas[j] = 0;
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += mas[i];
  }
  cout << ans << endl;
}
