#include <bits/stdc++.h>
using namespace std;
template <class T>
void cout_vec(const vector<T> &vec) {
  for (auto itr : vec) cout << itr << ' ';
  cout << endl;
}
const long long mod = 1e9 + 7;
const long long inf = 1e15;
int n, q;
string s;
vector<char> t(200010), d(200010);
bool left(int x) {
  int now = x;
  for (long long i = 0; i < q; i++) {
    if (t[i] == s[now]) {
      if (d[i] == 'L')
        now--;
      else
        now++;
    }
    if (now == -1) return true;
    if (now == n) break;
  }
  return false;
}
bool right(int x) {
  int now = x;
  for (long long i = 0; i < q; i++) {
    if (t[i] == s[now]) {
      if (d[i] == 'L')
        now--;
      else
        now++;
    }
    if (now == n) return true;
    if (now == -1) break;
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  cin >> s;
  for (long long i = 0; i < q; i++) cin >> t[i] >> d[i];
  int high = n, low = 0, mid;
  int ans1, ans2;
  while (high - low > 1) {
    mid = (high + low) / 2;
    if (left(mid))
      low = mid;
    else
      high = mid;
  }
  ans1 = low;
  high = n - 1, low = -1;
  while (high - low > 1) {
    mid = (high + low) / 2;
    if (right(mid))
      high = mid;
    else
      low = mid;
  }
  ans2 = high;
  if (ans1 >= ans2)
    cout << 0 << endl;
  else {
    cout << ans2 - ans1 - 1 << endl;
  }
}
