#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
int main() {
  int N, Q;
  string s;
  cin >> N >> Q >> s;
  vector<char> t, d;
  char c;
  for (int i = 0; i < Q; i++) {
    cin >> c;
    t.push_back(c);
    cin >> c;
    d.push_back(c);
  }
  int ans = N;
  vector<char> label;
  for (int i = 0; i < N; i++) {
    label.push_back(s[i]);
  }
  vector<int> cnt(N, 1);
  for (int i = 0; i < Q; i++) {
    if (d[i] == 'L') {
      for (int j = 0; j < N; j++) {
        if (label[j] == t[i]) {
          if (j == 0) {
            ans -= cnt[j];
            cnt[j] = 0;
          } else {
            cnt[j - 1] += cnt[j];
            cnt[j] = 0;
          }
        }
      }
    } else {
      for (int j = 0; j < N; j++) {
        if (label[j] == t[i]) {
          if (j == N - 1) {
            ans -= cnt[j];
            cnt[j] = 0;
          } else {
            cnt[j + 1] += cnt[j];
            cnt[j] = 0;
          }
        }
      }
    }
  }
  cout << ans << endl;
}
