#include <bits/stdc++.h>
#pragma GCC optimize("03")
using namespace std;
int n, q;
char c[200100];
pair<char, char> a[200100];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i <= q; i++) cin >> a[i].first >> a[i].second;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    int pos = i;
    for (int j = 1; j <= q; j++) {
      if (a[j].first != c[pos]) continue;
      if (a[j].second == 'L')
        pos--;
      else
        pos++;
      if (pos < 1 || pos > n) {
        cnt++;
        break;
      }
    }
  }
  cout << n - cnt;
  return 0;
}
