#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << " ";
    os << *it;
  }
  return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp) {
  for (auto x : mp) os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template <typename T, long long SIZE>
long long array_length(const T (&)[SIZE]) {
  return SIZE;
}
template <typename T, long long N>
void PRINTF(const T (&a)[N], long long s = N, long long t = -1, bool f = true) {
  if (t == -1) {
    for (long long i = 0; i < s; i++) {
      if (i) cout << " ";
      cout << a[i];
    }
  } else
    for (long long i = s; i < t; i++) {
      if (i != s) cout << " ";
      cout << a[i];
    }
  if (f) cout << "\n";
}
template <typename T, long long N1, long long N2>
void PRINTF(const T (&a)[N1][N2], long long h = N1, long long w = N2) {
  for (long long i = 0; i < h; i++) {
    for (long long j = 0; j < w; j++) {
      cout << a[i][j] << " \n"[j == w - 1];
    }
  }
}
string substr(const string &str, long long S1, long long S2 = -1) {
  if (S2 == -1) return str.substr(S1);
  return str.substr(S1, S2 - S1);
}
const long long inf = 1e9 + 7;
const long long INF = 1e18 + 7;
long long n, q;
string str;
vector<pair<char, char> > vec;
long long ni(long long now) {
  for (long long i = 0; i < q; i++) {
    if (str[now] != vec[i].first) continue;
    if (vec[i].second == 'L')
      now--;
    else
      now++;
    if (now < 0) return -1;
    if (n <= now) return 1;
  }
  return 0;
}
long long solve1() {
  long long l = -1, r = n - 1;
  while (l + 1 < r) {
    long long mid = (l + r) / 2;
    if (ni(mid) == -1)
      l = mid;
    else
      r = mid;
  }
  return l;
}
long long solve2() {
  long long l = 0, r = n;
  while (l + 1 < r) {
    long long mid = (l + r) / 2;
    if (ni(mid) == 1)
      r = mid;
    else
      l = mid;
  }
  return r;
}
signed main() {
  cin >> n >> q >> str;
  for (long long i = 0; i < q; i++) {
    char x, y;
    cin >> x >> y;
    vec.push_back(pair<char, char>(x, y));
  }
  long long l = solve1();
  long long r = solve2();
  if (l >= r)
    cout << 0 << endl;
  else
    cout << r - l - 1 << endl;
  return 0;
}
