#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<pair<char, char>> magic(q);
  for (int i = 0; i < q; i++) {
    cin >> magic[i].first >> magic[i].second;
  }
  vector<vector<bool>> vanish(2, vector<bool>(n, false));
  int now, prev;
  for (int i = q - 1; i >= 0; i--) {
    now = i % 2;
    prev = (i + 1) % 2;
    char word = magic[i].first;
    char direction = magic[i].second;
    for (int j = 0; j < n; j++) {
      if (word == s[j]) {
        if (j == 0 && direction == 'L') vanish[now][j] = true;
        if (j == n - 1 && direction == 'R') vanish[now][j] = true;
        if (0 <= j - 1 && direction == 'L') {
          vanish[now][j] = vanish[prev][j - 1];
        }
        if (j + 1 < n && direction == 'R') {
          vanish[now][j] = vanish[prev][j + 1];
        }
      } else {
        vanish[now][j] = vanish[prev][j];
      }
    }
  }
  int ans = n;
  for (int i = 0; i < n; i++) {
    if (vanish[now][i]) ans--;
  }
  cout << ans << endl;
}
