#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = 1e9 + 7;
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T> v) {
  for (int i = 0; i < v.size(); i++) {
    if (i > 0) {
      os << " ";
    }
    os << v[i];
  }
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<vector<T>> v) {
  for (int i = 0; i < v.size(); i++) {
    if (i > 0) {
      os << endl;
    }
    os << v[i];
  }
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(Q), d(Q);
  for (int i = 0; i < (int)Q; ++i) cin >> t[i] >> d[i];
  long long left = -1, right = N;
  for (int i = Q - 1; i >= 0; i--) {
    if (s[left + 1] == t[i] && d[i] == 'L') left++;
    if (s[right - 1] == t[i] && d[i] == 'R') right--;
  }
  if (right > left) {
    cout << N - (left + 1) - (N - right) << endl;
  } else {
    cout << N << endl;
  }
  return 0;
}
