#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF * INF * 10;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  string t, d;
  for (int i = 0; i < q; ++i) {
    string a, b;
    cin >> a >> b;
    t += a;
    d += b;
  }
  reverse(t.begin(), t.end());
  reverse(d.begin(), d.end());
  int l = -1, r = n;
  for (int i = 0; i < q; ++i) {
    if (l != n - 1 and s[l + 1] == t[i] and d[i] == 'L') l++;
    if (r and s[r - 1] == t[i] and d[i] == 'R') r--;
  }
  int ans = r - l - 1;
  if (ans < 0) ans = 0;
  cout << ans << endl;
}
