#include <bits/stdc++.h>
using namespace std;
int n, q;
char s;
int data[200005];
map<char, vector<int> > mp;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  int cnt = n;
  for (int i = 0; i < n; i++) {
    data[i] = 1;
    cin >> s;
    mp[s].push_back(i);
  }
  char t, d;
  for (int i = 0; i < q; i++) {
    cin >> t >> d;
    for (int j = 0; j < mp[t].size(); j++) {
      if (d == 'L') {
        if (data[mp[t][j]] > 0) {
          if (mp[t][j] == 0) {
            cnt -= data[mp[t][j]];
            data[mp[t][j]] = 0;
          } else {
            data[mp[t][j] - 1] += data[mp[t][j]];
            data[mp[t][j]] = 0;
          }
        }
      } else {
        if (data[mp[t][j]] > 0) {
          if (mp[t][j] == n - 1) {
            cnt -= data[mp[t][j]];
            data[mp[t][j]] = 0;
          } else {
            data[mp[t][j] + 1] += data[mp[t][j]];
            data[mp[t][j]] = 0;
          }
        }
      }
    }
  }
  cout << cnt << '\n';
  return 0;
}
