#include <bits/stdc++.h>
using namespace std;
constexpr double PI = 3.1415926535897932;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
using Pcc = pair<char, char>;
istream& operator>>(istream& is, Pcc& p) {
  char ch1, ch2;
  is >> ch1 >> ch2;
  p = Pcc(ch1, ch2);
  return is;
}
ostream& operator<<(ostream& os, const Pcc& p) {
  return os << p.first << ' ' << p.second << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<Pcc> query(n);
  for (int i = 0; i < q; ++i) cin >> query[i];
  int lb = -1, ub = n;
  while (ub - lb > 1) {
    int mid = (lb + ub) / 2;
    bool ok = true;
    int pos = mid;
    for (int i = 0; i < q; ++i) {
      if (s[pos] != query[i].first) continue;
      if (query[i].second == 'L')
        --pos;
      else
        ++pos;
      if (pos < 0) {
        ok = false;
        break;
      }
      if (pos >= n) break;
    }
    if (!ok)
      lb = mid;
    else
      ub = mid;
  }
  int left = ub;
  lb = -1, ub = n;
  while (ub - lb > 1) {
    int mid = (lb + ub) / 2;
    bool ok = true;
    int pos = mid;
    for (int i = 0; i < q; ++i) {
      if (s[pos] != query[i].first) continue;
      if (query[i].second == 'L')
        --pos;
      else
        ++pos;
      if (pos >= n) {
        ok = false;
        break;
      }
      if (pos < 0) break;
    }
    if (ok)
      lb = mid;
    else
      ub = mid;
  }
  int right = ub;
  int ans = max(0, right - left);
  cout << ans << endl;
}
