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