#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  return (b < a) ? (a = b, 1) : 0;
}
using ll = long long;
using R = long double;
const R EPS = 1e-9L;
inline int sgn(const R &r) { return (r > EPS) - (r < -EPS); }
inline R sq(R x) { return sqrt(max(x, 0.0L)); }
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const pid_t pid = getpid();
vector<string> split(const string &s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) { cerr << endl; }
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " ",
      err(++it, args...);
}
const int limit = 200010;
int out_l, out_r;
char t[limit], d[limit];
int main(void) {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  for (int i = int(0); i < int(q); ++i) cin >> t[i] >> d[i];
  out_l = 0, out_r = n + 1;
  for (int i = int(q) - 1; i >= int(0); --i) {
    if (out_r - out_l - 1 == 0) break;
    if (d[i] == 'L') {
      if (s[out_l] == t[i]) {
        out_l++;
      }
    } else {
      if (s[out_r - 2] == t[i]) {
        out_r--;
      }
    }
  }
  const int ans = out_r - out_l - 1;
  cout << ans << endl;
  return 0;
}
