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