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