#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 1e9 + 7;
int main() {
  int n, q;
  cin >> n >> q;
  vector<int> go(n, 1);
  map<char, vector<int>> masu;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    masu[c].push_back(i);
  }
  int cnt = n;
  for (int i = 0; i < q; i++) {
    char t;
    char d;
    cin >> t >> d;
    vector<int> taihi(n, 0);
    for (int basyo : masu[t]) {
      if (d == 'R') {
        if (basyo == n - 1) {
          cnt -= go[n - 1];
          go[n - 1] = 0;
        } else {
          taihi[basyo + 1] = go[basyo];
          go[basyo] = 0;
        }
      } else {
        if (basyo == 0) {
          cnt -= go[0];
          go[0] = 0;
        } else {
          taihi[basyo - 1] = go[basyo];
          go[basyo] = 0;
        }
      }
    }
    for (int j = 0; j < n; j++) {
      go[j] += taihi[j];
    }
  }
  cout << cnt << endl;
  return 0;
}
