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