#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
vector<char> t;
vector<char> d;
int calc(int target) {
  int index = target;
  for (int i = 0; i < Q; i++) {
    char c = s[index];
    if (t[i] == c) {
      if (d[i] == 'L') {
        index--;
      } else {
        index++;
      }
      if (index == -1) {
        return index;
      } else if (index == N) {
        return index;
      }
    }
  }
  return target;
}
int findL(int l, int r) {
  while (l <= r) {
    int mid = (l + r) / 2;
    if (calc(mid) == -1) {
      if (calc(mid + 1) == mid + 1) return mid;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return -1;
}
int findR(int l, int r) {
  while (l <= r) {
    int mid = (l + r) / 2;
    if (calc(mid) == N) {
      if (calc(mid - 1) == mid - 1) return mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  return -1;
}
int main() {
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < Q; i++) {
    char tt, dd;
    cin >> tt >> dd;
    t.push_back(tt);
    d.push_back(dd);
  }
  if (calc(0) == N || calc(N - 1) == -1) {
    cout << 0 << endl;
    return 0;
  }
  int l = findL(0, N - 1);
  int r = findR(0, N - 1);
  int count = N;
  if (l != -1) {
    count = count - (l + 1);
  }
  if (r != -1) {
    count = count - (N - r);
  }
  cout << count << endl;
  return 0;
}
