#include <bits/stdc++.h>
using namespace std;
bool isVowel(char c) {
  return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
bool prime[1000050];
void sieve() {
  fill(prime, prime + 1000050, 1);
  prime[0] = prime[1] = 0;
  for (int i = 2; i < 1000050; i++) {
    if (prime[i]) {
      for (int j = i * 2; j < 1000050; j += i) {
        prime[j] = 0;
      }
    }
  }
}
void mul(long long int a[2][2], long long int b[2][2]) {
  long long int p = a[0][0] * b[0][0] + a[0][1] * b[1][0];
  long long int q = a[0][0] * b[0][1] + a[0][1] * b[1][1];
  long long int r = a[1][0] * b[0][0] + a[1][1] * b[1][0];
  long long int s = a[1][0] * b[0][1] + a[1][1] * b[1][1];
  a[0][0] = p % 1000000007;
  a[0][1] = q % 1000000007;
  a[1][0] = r % 1000000007;
  a[1][1] = s % 1000000007;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  unordered_map<char, vector<int>> d;
  for (int i = 0; i < n; i++) {
    d[s[i]].push_back(i + 1);
  }
  int aa[n + 2];
  aa[0] = aa[n + 1] = 0;
  for (int i = 1; i <= n; i++) {
    aa[i] = 1;
  }
  while (q--) {
    char a, b;
    cin >> a >> b;
    for (int ind : d[a]) {
      if (b == 'L') {
        aa[ind - 1] += aa[ind];
        aa[ind] = 0;
      } else {
        aa[ind + 1] += aa[ind];
        aa[ind] = 0;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += aa[i];
  }
  cout << ans;
}
