#include <bits/stdc++.h>
using namespace std;
int static fast = []() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  return 0;
}();
bool to_zero(string s, string sq, string dir, int pos) {
  for (int i = 0; i < sq.size(); i++) {
    if (s[pos] == sq[i]) {
      if (dir[i] == 'L')
        pos -= 1;
      else
        pos += 1;
      if (pos == 0) return true;
    }
  }
  return false;
}
bool to_N1(string s, string sq, string dir, int pos) {
  for (int i = 0; i < sq.size(); i++) {
    if (s[pos] == sq[i]) {
      if (dir[i] == 'R')
        pos += 1;
      else
        pos -= 1;
      if (pos == s.length() - 1) return true;
    }
  }
  return false;
}
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  s = "@" + s + "@";
  string sq, dir;
  char c1, c2;
  for (int i = 0; i < Q; i++) {
    cin >> c1 >> c2;
    sq += c1;
    dir += c2;
  }
  int l = 0, r = N;
  while (l < r) {
    int m = l + (r - l) / 2;
    if (to_zero(s, sq, dir, m) == true) {
      l = m;
      if (r == l + 1) {
        r = (to_zero(s, sq, dir, r) == true) ? r : l;
        break;
      }
    } else {
      r = m - 1;
    }
  }
  int ans = N - (r);
  l = 1, r = N + 1;
  while (l < r) {
    int m = l + (r - l) / 2;
    if (to_N1(s, sq, dir, m) == false) {
      l = m + 1;
    } else {
      r = m;
    }
  }
  ans -= (N - r + 1);
  cout << ans << endl;
  return 0;
}
