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