#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long LINF = 1LL << 62;
const long long INF = 1 << 17;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<pair<char, char> > v, u;
  string t, c;
  for (int i = 0; i < q; i++) {
    char x, y;
    cin >> x >> y;
    v.push_back({x, y});
    u.push_back({x, y});
    if (y == 'L') t.push_back(x);
    if (y == 'R') c.push_back(x);
  }
  reverse(t.begin(), t.end());
  reverse(c.begin(), c.end());
  int k = 0, z = 0;
  for (int i = 0; i < q; i++) {
    if (v[i].second == 'L') v[i] = make_pair(t[k++], v[i].second);
  }
  for (int i = 0; i < q; i++) {
    if (u[i].second == 'R') u[i] = make_pair(c[z++], u[i].second);
  }
  int l = 0, r = n - 1;
  int la = 0, ra = 0;
  for (int i = 0; i < q; i++) {
    if (v[i].second == 'L') {
      if (v[i].first == s[l]) l++;
      if (v[i].first == s[r]) r = r;
    } else {
      if (u[i].first == s[r]) r--;
      if (u[i].first == s[l]) l = l;
    }
    la = max(la, l);
    ra = max(ra, n - 1 - r);
  }
  cout << n - (la + ra) << endl;
  return 0;
}
