#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = (ll)1e18;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4] = {1, 0, -1, 0};
constexpr int dy[4] = {0, 1, 0, -1};
template <typename T>
inline void pv(vector<T>& v) {
  for (ll i = 0, N = v.size(); i < N; i++)
    std::cout << v[i] << " \n"[i == N - 1];
}
template <typename T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  return a < b && (a = b, true);
}
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  return a > b && (a = b, true);
}
signed main() {
  ll N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<char> L, R;
  while (Q--) {
    char t, d;
    cin >> t >> d;
    if (d == 'L')
      L.push_back(t);
    else
      R.push_back(t);
  }
  reverse((L).begin(), (L).end());
  reverse((R).begin(), (R).end());
  ll ans, index;
  ans = 0;
  index = 0;
  for (ll i = 0, i_length = (L.size()); i < i_length; ++i) {
    if (S[index] == L[i]) index++;
  }
  ans += index;
  ;
  index = 0;
  for (ll i = 0, i_length = (R.size()); i < i_length; ++i) {
    if (S[N - 1 - index] == R[i]) index++;
  }
  ans += index;
  ;
  ;
  std::cout << N - ans << std::endl;
  return 0;
}
