#include <bits/stdc++.h>
using namespace std;
int n, q, ans;
string s;
char t[222222], d[222222];
int table[3214514];
int ha[31][2314514];
int pos[31];
bool use[222222];
int main() {
  cin >> n >> q >> s;
  for (int i = 0; i < n; i++) table[i] = 1, use[i] = 1;
  for (int i = 0; i < n; i++) {
    int tmp = s[i] - 'A';
    ha[tmp][pos[tmp]] = i;
    pos[tmp]++;
  }
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  for (int i = 0; i < n; i++) {
    if (!use[i]) continue;
    int cnt = 1, z = i;
    for (int j = 0; j < q; j++) {
      if (t[j] == s[z] && d[j] == 'L') {
        if (z == 0) {
          ans += cnt;
          break;
        } else if (s[z] != s[z - 1] && !use[z - 1]) {
          use[z - 1] = 0;
          cnt++;
          z--;
        } else {
          z--;
        }
      }
      if (t[j] == s[z] && d[j] == 'R') {
        if (z == n - 1) {
          ans += cnt;
          break;
        } else if (s[z] != s[z + 1] && !use[z + 1]) {
          use[z + 1] = 1;
          cnt++;
          z++;
        } else {
          z++;
        }
      }
    }
  }
  cout << n - ans << endl;
  return 0;
}
