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