#include <bits/stdc++.h>
using namespace std;
map<char, vector<pair<int, int>>> yukari;
map<char, int> mojisuu;
int hoge[200003] = {};
int main() {
  int N, Q;
  int dame = 0;
  string s;
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < N; i++) {
    yukari[s[i]].push_back(pair<int, int>(i + 1, 1));
    mojisuu[s[i]]++;
    hoge[i + 1] = 1;
  }
  for (int i = 0; i < Q; i++) {
    char ritsu;
    char aka;
    cin >> ritsu >> aka;
    for (int j = 0; j < mojisuu[ritsu]; j++) {
      yukari[ritsu][j].second = hoge[yukari[ritsu][j].first];
      if (aka == 'L') {
        hoge[yukari[ritsu][j].first - 1] += yukari[ritsu][j].second;
        hoge[yukari[ritsu][j].first] = 0;
      } else {
        hoge[yukari[ritsu][j].first + 1] += yukari[ritsu][j].second;
        hoge[yukari[ritsu][j].first] = 0;
      }
    }
  }
  cout << N - hoge[0] - hoge[N + 1] << endl;
  return 0;
}
