#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  int a[n];
  fill_n(a, n, 1);
  for (int i = 0; i < m; i++) {
    char t, d;
    cin >> t >> d;
    for (int j = 0; j < n; j++) {
      if (t == s[j]) {
        if (a[j] >= 1) {
          if (d == 'R') {
            if (j + 1 == n) {
            } else {
              a[j + 1] += a[j];
            }
          } else {
            if (j - 1 == -1) {
            } else {
              a[j - 1] += a[j];
            }
          }
          a[j] = 0;
        }
      }
    }
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != 0) {
      count += a[i];
    }
  }
  cout << count << endl;
}
