#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  char t, d;
  vector<int> a(n + 2, 1);
  for (int i = 0; i < q; i++) {
    cin >> t >> d;
    for (int j = 0; j < n; j++) {
      if (s[j] == t) {
        if (d == 'L')
          a[j] += a[j + 1];
        else
          a[j + 2] += a[j + 1];
        a[j + 1] = 0;
      }
    }
  }
  cout << n + 2 - a[0] - a[n + 1] << endl;
}
