#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const double pi = acos(-1.0);
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<char> t(q), d(q);
  for (int i = 0; i < (q); ++i) cin >> t[i] >> d[i];
  vector<int> cnt(n, 1);
  for (int i = 0; i < (q); ++i) {
    char T = t[i], M = d[i];
    for (int j = 0; j < (n); ++j) {
      if (s[j] == T) {
        if (M == 'L' && j != 0) {
          cnt[j - 1] += cnt[j];
          cnt[j] = 0;
        } else if (M == 'R' && j != n - 1) {
          cnt[j + 1] += cnt[j];
          cnt[j] = 0;
        } else {
          cnt[j] = 0;
        }
      }
    }
  }
  cout << (accumulate((cnt).begin(), (cnt).end(), 0)) << endl;
}
