#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[q], d[q];
  for (int i = 0; i < (q); ++i) {
    cin >> t[i] >> d[i];
  }
  int leftindex = 0;
  for (int i = (q - 1); i >= 0; --i) {
    if (s[leftindex] == t[i] and d[i] == 'L')
      leftindex++;
    else if (s[leftindex] == t[i] and d[i] == 'R')
      break;
  }
  int rightindex = n - 1;
  for (int i = (q - 1); i >= 0; --i) {
    if (s[rightindex] == t[i] and d[i] == 'R')
      rightindex--;
    else if (s[rightindex == t[i] and d[i] == 'L'])
      break;
  }
  cout << n - (leftindex + (n - rightindex - 1)) << endl;
  return 0;
}
