#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
void solve();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(numeric_limits<double>::max_digits10);
  solve();
  return 0;
}
inline vector<int> get_d(int n) { return vector<int>(n, INF); }
inline vector<ll> get_d(ll n) { return vector<ll>(n, LINF); }
template <typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>>& g) {
  T n = (int)g.size();
  priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q;
  vector<T> d = get_d(n);
  d[s] = 0;
  q.emplace(0, s);
  while (!q.empty()) {
    pair<T, int> p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (auto x : g[v]) {
      if (d[x.first] > d[v] + x.second) {
        d[x.first] = d[v] + x.second;
        q.emplace(d[x.first], x.first);
      }
    }
  }
  return d;
}
void solve() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<pair<char, char>> v(q);
  char t, d;
  for (int i = (0); i < ((q)); i++) {
    cin >> t >> d;
    v[q - 1 - i] = make_pair(t, d);
  }
  int l = 0;
  int r = n - 1;
  for (int i = (0); i < ((q)); i++) {
    if (s[l] == v[i].first && v[i].second == 'L') {
      l++;
    }
    if (s[r] == v[i].first && v[i].second == 'R') {
      r--;
    }
    if (l > r) {
      cout << 0 << EOL;
      return;
    }
  }
  cout << max(0, r - l + 1) << EOL;
}
