#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string s;
  cin >> N >> Q >> s;
  int m[200000];
  for (int i = 0; i < N; i++) {
    m[i] = 1;
  }
  int t[200000];
  int d[200000];
  for (int i = 0; i < Q; i++) {
    char a, b;
    cin >> a >> b;
    t[i] = a;
    d[i] = b;
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int p = i;
    cnt++;
    for (int j = 0; j < Q; j++) {
      if (s[p] != t[j]) continue;
      if (d[j] == 'L')
        p--;
      else
        p++;
      if (p < 0 || p >= N) {
        cnt--;
        break;
      }
    }
  }
  cout << cnt << endl;
}
void cheatsheet() {
  vector<int> vecloop;
  for (int i = 0; i < 10; i++) {
    vecloop.push_back(i);
  }
  int a = 1;
  int b = 5;
  swap(a, b);
  int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  sort(arr, arr + 9, greater<int>());
  vector<int> vec(arr, end(arr));
  sort(vec.begin(), vec.end());
  cout << lower_bound(vec.begin(), vec.end(), 2)[0];
  map<pair<long long, long long>, long long> m;
  m[pair<long long, long long>(10, 100)] = 100;
}
