#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline long long int rand(long long int x, long long int y) {
  ++y;
  return (rng() % (y - x)) + x;
}
long long int n, q;
string A;
pair<char, char> Q[(300006)];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q >> A;
  for (long long int i = 0; i < q; i++) cin >> Q[i].first >> Q[i].second;
  long long int st = -1, en = n, mid = 0;
  while (en - st > 1) {
    mid = (st + en) >> 1;
    long long int co = mid;
    bool can = 0;
    for (long long int i = 0; i < q; i++) {
      if (co >= n || co < 0) break;
      if (Q[i].first == A[co]) {
        co -= (Q[i].second == 'L');
        co += (Q[i].second == 'R');
      }
    }
    if (co == -1) can = 1;
    if (can)
      st = mid;
    else
      en = mid;
  }
  long long int tmp = st + 1;
  cerr << tmp << '\n';
  st = -1, en = n, mid = 0;
  while (en - st > 1) {
    mid = en - 1;
    long long int co = mid;
    bool can = 0;
    for (long long int i = 0; i < q; i++) {
      if (co >= n || co < 0) break;
      if (Q[i].first == A[co]) {
        co -= (Q[i].second == 'L');
        co += (Q[i].second == 'R');
      }
    }
    if (co >= n) can = 1;
    if (can)
      en = mid;
    else
      st = mid;
  }
  cerr << en << '\n';
  long long int out = tmp + (n - en);
  cout << n - out << '\n';
}
