#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  vector<char> t(q), d(q);
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  long long a, b;
  {
    auto check = [&](long long mid) {
      long long idx = mid;
      for (int i = 0; i < q; i++) {
        if (s[idx] == t[i]) {
          if (d[i] == 'L')
            idx -= 1;
          else
            idx += 1;
          if (idx < 0) return true;
        }
      }
      return false;
    };
    long long lb = -1, ub = n;
    while (ub - lb > 1) {
      long long mid = (lb + ub) / 2;
      if (check(mid))
        lb = mid;
      else
        ub = mid;
    }
    a = lb;
  }
  {
    auto check = [&](long long mid) {
      long long idx = mid;
      for (int i = 0; i < q; i++) {
        if (s[idx] == t[i]) {
          if (d[i] == 'L')
            idx -= 1;
          else
            idx += 1;
          if (idx >= n) return true;
        }
      }
      return false;
    };
    long long lb = -1, ub = n;
    if (ub - lb > 1) {
      long long mid = (lb + ub) / 2;
      if (check(mid))
        ub = mid;
      else
        lb = mid;
    }
    b = ub;
  }
  if (b <= a)
    cout << 0 << endl;
  else
    cout << b - a - 1 << endl;
}
