#include <bits/stdc++.h>
using namespace std;
using P = pair<long long, long long>;
using mat = vector<vector<long long>>;
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
const long long INF = 1e16;
const long long MOD = 1e9 + 7;
const long double EPS = 1e-12;
template <typename T>
void dump(T x) {
  cout << x << endl;
}
void dumpf(long double x, int t) {
  cout << setprecision(t) << fixed << x << endl;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}
inline long long mod(long long a, long long b) {
  if (a > 0) return a % b;
  if (a % b == 0) return 0;
  long long x = -a / b + 1;
  a += x * b;
  return a % b;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
signed main() {
  IOS();
  long long n, q;
  string s;
  cin >> n >> q >> s;
  vector<pair<char, char>> a(q);
  for (int i = 0; i < q; i++) {
    cin >> a[i].first >> a[i].second;
  }
  long long left = -1, right = n;
  while (left < right - 1) {
    long long mid = (left + right) / 2;
    long long now = mid;
    for (int i = 0; i < q; i++) {
      if (now == -1) {
        break;
      }
      if (s[now] == a[i].first) {
        if (a[i].second == 'R')
          now++;
        else
          now--;
      }
    }
    if (now == -1) {
      left = mid;
    } else {
      right = mid;
    }
  }
  left++;
  long long left2 = 0, right2 = n + 1;
  while (left2 < right2 - 1) {
    long long mid = (left2 + right2) / 2;
    long long now = mid;
    for (int i = 0; i < q; i++) {
      if (now == -1) {
        break;
      }
      if (s[now] == a[i].first) {
        if (a[i].second == 'R')
          now++;
        else
          now--;
      }
    }
    if (now == n) {
      right2 = mid;
    } else {
      left2 = mid;
    }
  }
  long long unko = n - right2;
  dump(max(0ll, n - left - unko));
  return 0;
}
