#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, q, ans = 0;
  cin >> n >> q;
  vector<pair<char, int>> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i).first;
    v.at(i).second = 1;
  }
  for (int j = 0; j < q; j++) {
    char a, b;
    cin >> a >> b;
    for (int k = 0; k < v.size(); k++) {
      if (v.at(k).first == a) {
        if (b == 'L' && k != 0) {
          v.at(k - 1).second += v.at(k).second;
        } else if (b == 'R' && k != n - 1) {
          v.at(k + 1).second += v.at(k).second;
        }
        v.at(k).second = 0;
      }
    }
  }
  for (int i = 0; i < v.size(); i++) {
    ans += v.at(i).second;
  }
  cout << ans << endl;
}
