#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long long int INF = (long long int)1e15;
pair<char, char> C[200005];
int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  for (long long int(i) = (0); (i) < (Q); ++(i)) {
    cin >> C[i].first >> C[i].second;
  }
  long long int ans = N;
  {
    int li = 0;
    int pi = 0;
    long long int k = 0;
    int m = 0;
    int n = 0;
    for (int i = Q - 1; i >= 0; --i) {
      if (C[i].first == S[li] && C[i].second == 'L') {
        li++;
        pi = li;
        n += m + 1;
        m = k;
        k = 0;
      } else if (pi >= 0 && C[i].first == S[pi] && C[i].second == 'R') {
        pi--;
        k++;
      }
    }
    n -= k;
    ans -= n;
  }
  {
    int li = N - 1;
    int pi = N - 1;
    long long int k = 0;
    int m = 0;
    int n = 0;
    for (int i = Q - 1; i >= 0; --i) {
      if (C[i].first == S[li] && C[i].second == 'R') {
        li--;
        pi = li;
        n += m + 1;
        m = k;
        k = 0;
      } else if (pi < N && C[i].first == S[pi] && C[i].second == 'L') {
        pi++;
        k++;
      }
    }
    n -= k;
    ans -= n;
  }
  cout << ans << endl;
  return 0;
}
