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