#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  int* g = new int[n];
  for (int i = 0; i < n; i++) {
    g[i] = 1;
  }
  int ans = 0;
  for (int i = 0; i < q; i++) {
    char ch, ch2;
    cin >> ch >> ch2;
    int j = 0;
    for (int j = 0; j < n; j++) {
      if (ch == s[j]) {
        if (ch2 == 'L') {
          if (j == 0) {
            ans += g[j];
            g[j] = 0;
            continue;
          }
          g[j - 1] += g[j];
          g[j] = 0;
        } else {
          if (j == n - 1) {
            ans += g[j];
            g[j] = 0;
            continue;
          }
          g[j + 1] += g[j];
          g[j] = 0;
        }
      }
    }
  }
  cout << n - ans << endl;
  return 0;
}
