#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int INF = numeric_limits<int>::max() / 2;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<pair<char, char> > route;
  for (int i = 0; i < q; i++) {
    char a, b;
    cin >> a >> b;
    route.push_back(make_pair(a, b));
  }
  reverse(route.begin(), route.end());
  ll left = 0;
  ll right = n;
  for (int i = 0; i < q; i++) {
    auto p = route[i];
    if (p.second == 'R') {
      if (p.first == s[right - 1]) {
        right--;
      } else if (left != 0 && p.first == s[left - 1]) {
        left--;
      }
    } else if (p.second == 'L') {
      if (p.first == s[left]) {
        left++;
      } else if (right != n && p.first == s[right]) {
        right++;
      }
    }
  }
  cout << max(0LL, right - left) << endl;
  return 0;
}
