#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
signed main(void) {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int N, Q;
  cin >> N >> Q;
  ;
  string S;
  cin >> S;
  ;
  unordered_map<char, map<int, int> > m;
  for (int i = 0; i < N; i++) {
    m[S[i]][i] = 1;
  }
  int ans = N;
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    char fromChar = t;
    int diff = ((d == 'L') ? -1 : 1);
    for (auto &i : m[fromChar]) {
      int toIndex = i.first + diff;
      if (toIndex < 0 or toIndex >= N) {
        ans -= i.second;
        i.second = 0;
        continue;
      }
      for (int k = 0; k < 'Z' - 'A' + 1; k++) {
        auto it = m['A' + k].find(toIndex);
        if (it != m['A' + k].end()) {
          (*it).second += i.second;
          i.second = 0;
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
