#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, q;
  cin >> n >> q;
  string str;
  cin >> str;
  ll N = str.size();
  vector<ll> nums(N);
  for (ll i = 0; i < nums.size(); i++) nums[i] = 1;
  for (ll j = 0; j < q; j++) {
    char t, d;
    cin >> t >> d;
    for (ll i = 0; i < str.size(); i++) {
      if (str[i] == t) {
        if (d == 'R') {
          if (i + 1 < n) nums[i + 1] += nums[i];
          nums[i] = 0;
        } else {
          if (i - 1 >= 0) nums[i - 1] += nums[i];
          nums[i] = 0;
        }
      }
    }
  }
  ll cnt = 0;
  for (ll i = 0; i < nums.size(); i++) {
    cnt += nums[i];
  }
  cout << cnt << endl;
  return 0;
}
