#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1e9 + 7;
constexpr long long INFL = 1e18;
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
int n, q;
string S;
vector<pair<char, char>> spells;
int sim(int x) {
  for (auto& p : spells) {
    if (S[x] == p.first) x += (p.second == 'L' ? -1 : 1);
    if (x == -1 or x == n) return x;
  }
  return x;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q >> S;
  spells.resize(q);
  for (auto& p : spells) cin >> p.first >> p.second;
  int L = 0, R = n;
  while (L + 1 < R) {
    auto S = (L + R) / 2 - 1;
    if (sim(S) == -1)
      L = S + 1;
    else
      R = S + 1;
  }
  int a = L;
  L = -1, R = n - 1;
  while (L + 1 < R) {
    auto S = (L + R) / 2 + 1;
    if (sim(S) == n)
      R = S - 1;
    else
      L = S - 1;
  }
  int b = R;
  cout << max(0, b - a + 1) << "\n";
}
