#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<long long>;
using vvl = vector<vl>;
using P = pair<long long, long long>;
using PP = pair<long long, P>;
using vp = vector<P>;
using vpp = vector<PP>;
using vs = vector<string>;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename A, typename B>
istream &operator>>(istream &is, pair<A, B> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &t) {
  for (int i = 0; i < (t.size()); i++) is >> t[i];
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
  os << "{";
  for (int i = 0; i < (t.size()); i++) {
    if (i) os << ",";
    os << t[i];
  }
  cout << "}";
  return os;
}
const long long MOD = 1000000007LL;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
int main() {
  int n, q;
  cin >> n >> q;
  string st;
  cin >> st;
  vector<pair<string, string>> vec(q);
  cin >> vec;
  reverse(vec.begin(), vec.end());
  int l = 0, r = n - 1;
  for (int i = 0; i < (q); i++) {
    if (r < l) {
      break;
    }
    if (vec[i].second == "L") {
      if (st[l] == vec[i].first[0]) {
        l++;
      }
    } else {
      if (st[r] == vec[i].first[0]) {
        r--;
      }
    }
  }
  cout << max(0, r - l + 1) << endl;
  return 0;
}
