#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
template <class T>
using V = vector<T>;
template <class T>
using vv = vector<V<T>>;
template <class T>
using VV = vector<V<T>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9 + 7;
void cioacc() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main() {
  int n, q;
  cin >> n >> q;
  string s, t;
  cin >> s;
  vi grm(n, 1);
  vb left(q);
  for (ll i = (0); i < (ll)(q); ++i) {
    char tmp;
    cin >> tmp;
    t += tmp;
    cin >> tmp;
    if (tmp == 'L')
      left[i] = true;
    else
      left[i] = false;
  }
  for (ll i = (0); i < (ll)(q); ++i) {
    int id = 0;
    while ((id = (int)s.find(t[i], id)) != -1) {
      if (grm[id] == 0) {
        ++id;
        continue;
      }
      if (id == 0 && left[i])
        grm[id] = 0;
      else if (id == n - 1 && !left[i])
        grm[id] = 0;
      else {
        if (left[i])
          grm[id - 1] += grm[id];
        else
          grm[id + 1] += grm[id];
        grm[id] = 0;
      }
      ++id;
    }
  }
  cout << accumulate((grm).begin(), (grm).end(), 0) << endl;
}
