#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 n, q;
string s;
pair<char, char> a[100000];
bool f(int m) {
  char tar = s[m];
  int i = m;
  for (auto e : a) {
    if (e.first == tar) {
      e.second == 'L' ? i-- : i++;
      if (i == -1) {
        return true;
      }
      tar = s[i];
    }
  }
  return false;
}
bool g(int m) {
  char tar = s[m];
  int i = m;
  for (auto e : a) {
    if (e.first == tar) {
      e.second == 'L' ? i-- : i++;
      if (i == n) {
        return true;
      }
      tar = s[i];
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) {
    cin >> a[i].first >> a[i].second;
  }
  int left = -1, right = n;
  int l = 0, r = n - 1;
  while (l <= r) {
    int m = (l + r) / 2;
    if (f(m)) {
      left = m;
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  l = 0, r = n - 1;
  while (l <= r) {
    int m = (l + r) / 2;
    if (g(m)) {
      right = m;
      r = m - 1;
    } else {
      l = m + 1;
    }
  }
  cout << max(0, right - left - 1);
}
