#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  int gorem[n];
  for (int i = 0; i < (n); ++i) gorem[i] = 1;
  for (int i = 0; i < (q); ++i) {
    char W, Q;
    cin >> W >> Q;
    for (int i = 0; i < (n); ++i) {
      if (W == s[i]) {
        if (Q == 'R' && gorem[i] != 0) {
          gorem[i + 1] += gorem[i];
          gorem[i] = 0;
        } else if (Q == 'L' && gorem[i] != 0) {
          gorem[i - 1] += gorem[i];
          gorem[i] = 0;
        }
      }
    }
  }
  long res = 0;
  for (int i = 0; i < (n); ++i) res += gorem[i];
  cout << res << endl;
}
