#include <bits/stdc++.h>
using namespace std;
inline void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
inline void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
inline void Yay(bool b) { cout << (b ? "Yay!" : ":(") << endl; }
string s;
vector<pair<char, char> > v;
int N, Q;
int move(int pos) {
  for (int i = 0, i_max = (Q); i < i_max; ++i) {
    if (s[pos] == v[i].first) {
      if (v[i].second == 'L')
        --pos;
      else
        ++pos;
    }
  }
  return pos;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(15);
  cin >> N >> Q;
  cin >> s;
  s = " " + s + " ";
  v.resize(N);
  for (int i = 0, i_max = (Q); i < i_max; ++i) cin >> v[i].first >> v[i].second;
  int ls = 0, le = N + 1;
  while (le - ls > 1) {
    int lm = (ls + le) / 2;
    if (move(lm) == 0)
      ls = lm;
    else
      le = lm;
  }
  int rs = 0, re = N + 1;
  while (re - rs > 1) {
    int rm = (rs + re) / 2;
    if (move(rm) == N + 1)
      re = rm;
    else
      rs = rm;
  }
  cout << N - ls - (N + 1 - re) << endl;
  return 0;
}
