#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, Q;
  string s;
  cin >> N >> Q;
  vector<pair<char, long long>> golem;
  map<char, pair<long long, long long>> golem_map;
  s.push_back('0');
  for (long long i = 0; i < N; ++i) {
    char buf;
    cin >> buf;
    s.push_back(buf);
    golem.push_back(make_pair(i + 1, buf));
  }
  long long gone = 0;
  for (long long i = 0; i < Q; ++i) {
    char buf[2];
    cin >> buf[0] >> buf[1];
    long long ho;
    if (buf[1] == 'R')
      ho = 1;
    else if (buf[1] == 'L')
      ho = -1;
    for (long long j = 0; j < N - gone; ++j) {
      if (golem[j].second == buf[0]) {
        golem[j].first += ho;
        if (golem[j].first < 1 || N < golem[j].first) {
          golem.erase(golem.begin() + j);
          --j;
          ++gone;
        } else {
          golem[j].second = s[golem[j].first];
        }
      }
    }
  }
  cout << N - gone << endl;
  return 0;
}
