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