#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = ((ll)1e9) + 7;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
template <class T, size_t N, class A = size_t>
auto mdv(A size = 0) -> typename enable_if<N == 1, vector<T>>::type {
  return vector<T>(size);
}
template <class T, size_t N, class A = size_t>
auto mdv(A size = 0) -> vector<decltype(mdv<T, N - 1>())> {
  return vector<decltype(mdv<T, N - 1>())>(size);
}
template <class T, size_t N, class A, class... B>
auto mdv(A size, B... rest) ->
    typename enable_if<N != 1, vector<decltype(mdv<T, N - 1>(rest...))>>::type {
  return vector<decltype(mdv<T, N - 1>(rest...))>(size, mdv<T, N - 1>(rest...));
}
template <class T, class... A>
auto mdv(A... size) -> decltype(mdv<T, sizeof...(size), A...>(size...)) {
  return mdv<T, sizeof...(size), A...>(size...);
}
template <class T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
void input(T& t) {
  cin >> t;
  assert(cin);
}
template <class T, class... Ts>
void input(T& t, Ts&... ts) {
  cin >> t;
  input(ts...);
}
template <class T>
void print(T&& t) {
  cout << t;
}
template <class T, class... Ts>
void print(T&& t, Ts&&... ts) {
  cout << t;
  print(ts...);
}
template <class T>
void println(T&& t) {
  cout << t << endl;
}
template <class T, class... Ts>
void println(T&& t, Ts&&... ts) {
  cout << t;
  println(ts...);
}
template <class T>
string join(const vector<T>& v, const string& sep) {
  stringstream ss;
  for (ll i = 0; i < (v.size()); ++i) ss << (i != 0 ? sep : "") << v[i];
  return ss.str();
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(50);
  ll n, q;
  string s;
  cin >> n >> q >> s;
  vector<vector<char>> vs(q, vector<char>(2));
  for (ll i = 0; i < (q); ++i)
    for (ll j = 0; j < (2); ++j) cin >> vs[i][j];
  reverse((vs).begin(), (vs).end());
  ll r = n;
  for (ll i = 0; i < (q); ++i)
    if (r > 0 && vs[i][0] == s[r - 1] && vs[i][1] == 'R') r--;
  ll l = -1;
  for (ll i = 0; i < (q); ++i)
    if (l < n - 1 && vs[i][0] == s[l + 1] && vs[i][1] == 'L') l++;
  cout << max(0ll, n - (n - r) - (l + 1)) << endl;
}
