#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<long long> g(n, 1);
  for (long long i = 0; i < q; ++i) {
    char t, d;
    cin >> t >> d;
    for (long long j = 0; j < n; ++j) {
      if (s[j] == t) {
        if (d == 'L' && j != 0) {
          g[j - 1] += g[j];
        }
        if (d == 'R' && j != n - 1) {
          g[j + 1] += g[j];
        }
        g[j] = 0;
      }
    }
  }
  long long count = 0;
  for (auto&& e : g) {
    count += e;
  }
  cout << count << endl;
}
