#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<pair<char, char>> q(Q);
  for (ll i = 0, i_length = (Q); i < i_length; ++i) {
    char t, d;
    cin >> t >> d;
    q[i].first = t;
    q[i].second = d;
  }
  ll lindex = 0, rindex = 0, lmachi = -1, rmachi = -1;
  for (auto it = q.rbegin(); it != q.rend(); it++) {
    char t = it->first;
    char d = it->second;
    if (d == 'L') {
      if (rmachi != -1 && S[rmachi] == t) rmachi--;
      if (S[rindex] == t && rindex - 1 == rmachi) {
        rindex++;
        rmachi++;
      }
    } else {
      if (rmachi != -1 && S[rmachi] == t) rmachi++;
    };
    if (d == 'R') {
      if (lmachi != -1 && S[N - 1 - lmachi] == t) lmachi--;
      if (S[N - 1 - lindex] == t && lindex - 1 == lmachi) {
        lindex++;
        lmachi++;
      }
    } else {
      if (lmachi != -1 && S[N - 1 - lmachi] == t) lmachi++;
    };
  }
  std::cout << N - lindex - rindex << std::endl;
  return 0;
}
