#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, Q;
  cin >> N >> Q;
  auto now = vector<long long int>(N, 1);
  string S;
  cin >> S;
  vector<pair<char, char>> Query(Q);
  for (size_t i = 0; i < Q; i++) {
    cin >> Query[i].first >> Query[i].second;
  }
  long long int begin = -1, end = N;
  for (auto now = Query.rbegin(); now < Query.rend(); now++) {
    auto ope = *now;
    if (0 <= begin + 1 && begin + 1 < N && ope.first == S[begin + 1] &&
        ope.second == 'L') {
      begin++;
    } else if (0 <= begin - 1 && begin - 1 < N && ope.first == S[begin - 1] &&
               ope.second == 'R') {
    }
    if (0 <= end + 1 && end + 1 < N && ope.first == S[end + 1] &&
        ope.second == 'L') {
    } else if (0 <= end - 1 && end - 1 < N && ope.first == S[end - 1] &&
               ope.second == 'R') {
      end--;
    }
    if (begin + 1 == end) {
      break;
    }
  }
  cout << end - begin - 1 << endl;
}
