#include <bits/stdc++.h>
using namespace std;
using pchar = pair<char, char>;
int simulate(const string &s, const vector<pchar> &td, int pos) {
  for (auto c : td) {
    if (s[pos] != c.first) continue;
    if (c.second == 'L')
      --pos;
    else
      ++pos;
    if (pos < 0) return -1;
    if (pos >= (int)s.size()) return 1;
  }
  return 0;
}
int solve(const string &s, const vector<pchar> &td) {
  int N = (int)s.size();
  int low = -1, high = N;
  while (high - low > 1) {
    int mid = (low + high) / 2;
    if (simulate(s, td, mid) == 0)
      high = mid;
    else
      low = mid;
  }
  int left_fall = high;
  low = -1, high = N;
  while (high - low > 1) {
    int mid = (low + high) / 2;
    if (simulate(s, td, mid) == 0)
      low = mid;
    else
      high = mid;
  }
  int right_fall = N - 1 - low;
  return N - (left_fall + right_fall);
}
int main() {
  int N, Q;
  string s;
  cin >> N >> Q >> s;
  vector<pchar> td(Q);
  for (int i = 0; i < Q; ++i) cin >> td[i].first >> td[i].second;
  cout << solve(s, td) << endl;
}
