#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = 1ll << 61;
struct edge {
  long long to;
  long long to2;
  long long cost;
};
signed main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  string sl = "%", sv = "%";
  for (long long i = 0; i < q; i++) {
    char a, b;
    cin >> a >> b;
    sl.push_back(a);
    sv.push_back(b);
  }
  sl.push_back('%');
  sv.push_back('%');
  long long cnt = 0;
  long long pos = n - 1;
  for (long long i = q; i > 0; i--) {
    if (sl[i] == s[pos]) {
      if (sv[i] == 'R') {
        cnt++;
        pos--;
      }
    } else if (pos != n - 1 && sl[i] == s[pos + 1]) {
      if (sv[i] == 'L') {
        cnt--;
        pos++;
      }
    }
  }
  pos = 0;
  for (long long i = q; i > 0; i--) {
    if (sl[i] == s[pos]) {
      if (sv[i] == 'L') {
        cnt++;
        pos++;
      }
    } else if (pos != 0 && sl[i] == s[pos - 1]) {
      if (sv[i] == 'R') {
        cnt--;
        pos--;
      }
    }
  }
  cout << n - cnt << endl;
}
