#include <bits/stdc++.h>
using namespace std;
long long N, Q;
vector<long long> alpha[100];
pair<char, long long> order[200000];
long long nums[200000];
long long out;
int main(void) {
  cin >> N >> Q;
  for (long long i = 0; i < N; i++) {
    nums[i] = 1;
    char a;
    cin >> a;
    alpha[a].push_back(i);
  }
  for (long long i = 0; i < Q; i++) {
    char a, b;
    cin >> a >> b;
    order[i].first = a;
    if (b == 'L') {
      order[i].second = 0;
    } else {
      order[i].second = 1;
    }
    for (long long j = 0; j < alpha[a].size(); j++) {
      long long now = alpha[a][j];
      if (order[i].second == 0) {
        if (now == 0) {
          out += nums[0];
          nums[0] = 0;
        } else {
          nums[now - 1] += nums[now];
          nums[now] = 0;
        }
      } else {
        if (now == N - 1) {
          out += nums[N - 1];
          nums[N - 1] = 0;
        } else {
          nums[now + 1] += nums[now];
          nums[now] = 0;
        }
      }
    }
  }
  cout << N - out << endl;
  return 0;
}
