#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int q;
  cin >> q;
  std::vector<int> s;
  for (int i = 0; i < n; i++) {
    s.push_back(1);
  }
  string s1;
  cin >> s1;
  for (int i = 0; i < q; i++) {
    char c, b;
    cin >> c >> b;
    if (b == 'L') {
      for (int j = 0; j < n; j++) {
        if (c == s1[j]) {
          if (j == 0) {
            s[j] = 0;
          } else {
            s[j - 1] += s[j];
            s[j] = 0;
          }
        }
      }
    }
    if (b == 'R') {
      for (int j = 0; j < n; j++) {
        if (c == s1[j]) {
          if (j == n - 1) {
            s[j] = 0;
          } else {
            s[j + 1] += s[j];
            s[j] = 0;
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += s[i];
  }
  cout << ans << endl;
}
