#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  vector<int> g(N + 2, 1);
  g[0] = 0;
  g[N + 1] = 0;
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    if (d == 'R') {
      for (int j = 0; j < N; j++) {
        if (s[j] == t && g[j + 1] != 0) {
          g[j + 2] += g[j + 1];
          g[j + 1] = 0;
        }
      }
    } else {
      for (int j = 0; j < N; j++) {
        if (s[j] == t && g[j + 1] != 0) {
          g[j] += g[j + 1];
          g[j + 1] = 0;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += g[i];
  }
  cout << ans << endl;
}
