#include <bits/stdc++.h>
using namespace std;
using int_ = int;
int_ main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  int_least64_t n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<pair<char, char> > events;
  for (int_least64_t i = 0; i < m; ++i) {
    char a, b;
    cin >> a >> b;
    events.emplace_back(a, b);
  }
  reverse(events.begin(), events.end());
  int_least64_t l = -1, r = n;
  int_least64_t maxl = 0, minr = n;
  for (auto [t, d] : events) {
    int_least64_t dir = d == 'L' ? 1 : -1;
    if (0 <= l + dir && l + dir < n && t == s[l + dir]) {
      l += dir;
    }
    if (0 <= r + dir && r + dir < n && t == s[r + dir]) {
      r += dir;
    }
    maxl = max(l, maxl);
    minr = min(r, minr);
  }
  cout << max<int_least64_t>(0, minr - maxl - 1) << '\n';
}
