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