#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> a(n, 1);
  for (int i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    for (int j = 0; j < n; j++) {
      if (t == s.at(j)) {
        int num = a.at(j);
        a.at(j) = 0;
        if (d == 'L' and j != 0) {
          a.at(j - 1) += num;
        } else if (d == 'R' and j != n - 1) {
          a.at(j + 1) += num;
        }
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  cout << sum << endl;
}
