#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
vector<int> counter;
map<char, vector<int>> indexes;
int main() {
  cin >> N >> Q;
  cin >> s;
  counter.resize(N, 1);
  for (int i = 0; i < N; i++) {
    indexes[s[i]].push_back(i);
  }
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    if (indexes.find(t) != indexes.end()) {
      for (int j = 0; j < indexes[t].size(); j++) {
        int index = indexes[t][j];
        if (d == 'R' && index != N - 1) {
          counter[index + 1] += counter[index];
        } else if (d == 'L' && index != 0) {
          counter[index - 1] += counter[index];
        }
        counter[index] = 0;
      }
    }
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    count += counter[i];
  }
  cout << count << endl;
}
