#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  int N, Q;
  string s;
  string t, d;
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < Q; i++) {
    char a, b;
    cin >> a >> b;
    t.push_back(a);
    d.push_back(b);
  }
  int l = 0, r = 0;
  for (int i = Q - 1; i > -1; i--) {
    if (s.at(l) == t.at(i) && d.at(i) == 'L') {
      l++;
    } else if (l > 0 && s.at(l - 1) == t.at(i) && d.at(i) == 'R') {
      l--;
    }
  }
  for (int i = Q - 1; i > -1; i--) {
    if (s.at(N - r - 1) == t.at(i) && d.at(i) == 'R') {
      r++;
    } else if (r < N - 1 && s.at(N - r - 2) == t.at(i) && d.at(i) == 'L') {
      r--;
    }
  }
  cout << N - l - r << endl;
}
