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