#include <bits/stdc++.h>
using namespace std;
int main() {
  map<char, vector<int>> mp;
  char a[200200];
  int f[200200];
  int n, m, ans;
  cin >> n >> m;
  ans = n;
  for (int i = 0; i < n; i++) f[i] = 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    char x, y;
    cin >> x >> y;
    vector<pair<int, int>> v;
    for (int j : mp[x]) {
      if (y == 'L') v.push_back(make_pair(j - 1, f[j]));
      if (y == 'R') v.push_back(make_pair(j + 1, f[j]));
    }
    for (int j = 0; j < v.size(); j++) {
      if (y == 'L') {
        if (v[j].first == -1)
          ans -= v[j].second;
        else
          f[v[j].first] += v[j].second;
        f[v[j].first + 1] -= v[j].second;
      }
      if (y == 'R') {
        if (v[j].first == n)
          ans -= v[j].second;
        else
          f[v[j].first] += v[j].second;
        f[v[j].first - 1] -= v[j].second;
      }
    }
  }
  cout << ans;
}
