#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& a) {
  return os << "(" << a.first << "," << a.second << ")";
}
template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << (*i) << " ";
  cout << endl;
}
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
const int MAX_N = 212345;
const int MAX_Q = 212345;
pair<char, char> qs[MAX_Q];
int main2() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  for (int i = 0, _n = (int)(Q); i < _n; ++i) {
    cin >> qs[i].first;
    cin >> qs[i].second;
  }
  int left = -1;
  int right = N;
  for (int i = Q - 1; i >= 0; i--) {
    int t = qs[i].first;
    int d = qs[i].second;
    if (d == 'L') {
      if (s[left + 1] == t) {
        left++;
      }
    } else {
      if (s[right - 1] == t) {
        right--;
      }
    }
    if (right - left - 1 <= 0) break;
  }
  int ans = right - left - 1;
  cout << ans << endl;
  return 0;
}
int main() {
  for (; !cin.eof(); cin >> ws) main2();
  return 0;
}
