#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[1000000], d[1000000];
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  int l = 0, r = n - 1, mid, v, ans = n;
  while (r - l != 1) {
    mid = (l + r) / 2;
    v = mid;
    for (int i = 0; i < q; i++) {
      if (s[v] == t[i]) {
        if (d[i] == 'L') {
          v--;
          if (v < 0) {
            break;
          }
        } else {
          v++;
        }
      }
    }
    if (v < 0) {
      l = mid;
    } else {
      r = mid;
    }
  }
  ans -= l + 1;
  l = -1;
  r = n;
  while (r - l != 1) {
    mid = (l + r) / 2;
    v = mid;
    for (int i = 0; i < q; i++) {
      if (s[v] == t[i]) {
        if (d[i] == 'L') {
          v--;
          if (v > n - 1) {
            break;
          }
        } else {
          v++;
        }
      }
    }
    if (v > n - 1) {
      r = mid;
    } else {
      l = mid;
    }
  }
  ans -= n - r;
  cout << ans << endl;
}
