#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e+17;
const long long MODcdf = 998244353;
bool pairCompare(const pair<long long, long long>& firstElof,
                 const pair<long long, long long>& secondElof) {
  return firstElof.first < secondElof.first;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[q], d[q];
  for (long long i = 0; i < q; i++) cin >> t[i] >> d[i];
  long long mas[n];
  for (long long i = 0; i < n; i++) mas[i] = 1;
  for (long long i = 0; i < q; i++) {
    if (s[0] == t[i] && mas[0] && d[i] == 'L')
      mas[0] = 0;
    else if (s[n - 1] == t[i] && mas[n - 1] && d[i] == 'R')
      mas[n - 1] = 0;
    if (d[i] == 'R') {
      for (long long j = 0; j < n - 1; j++) {
        if (s[j] == t[i]) {
          mas[j + 1] += mas[j];
          mas[j] = 0;
        }
      }
    } else {
      for (long long j = 1; j < n; j++) {
        if (s[j] == t[i]) {
          mas[j - 1] += mas[j];
          mas[j] = 0;
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (mas[i]) ans += mas[i];
  }
  cout << ans << endl;
}
