#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, q;
  cin >> n >> q;
  char arr[n];
  char a, b, c;
  long long ar[n];
  for (long long i = 0; i < n; i++) {
    ar[i] = 1;
  }
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (long long i = 0; i < q; i++) {
    cin >> a;
    cin >> b;
    for (long long j = 0; j < n; j++) {
      if (arr[j] == a) {
        if (b == 'L') {
          if (ar[j] > 0) {
            if (j != 0) ar[j - 1] += ar[j];
            ar[j] = 0;
          }
        } else if (b == 'R') {
          if (ar[j] > 0) {
            if (j != n - 1) ar[j + 1] += ar[j];
            ar[j] = 0;
          }
        }
      }
    }
  }
  long long m = 0;
  for (long long i = 0; i < n; i++) m += ar[i];
  cout << m << '\n';
  return 0;
}
