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