#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void CHMAX(T& a, const T b) {
  if (a < b) a = b;
}
template <typename T>
inline void CHMIN(T& a, const T b) {
  if (a > b) a = b;
}
const long long MOD = 1000000007ll;
const double EPS = 1e-11;
int n, q;
string s;
char t[252521], d[252521];
bool is_ok1(int mid) {
  for (int i = 0; i < (q); ++i) {
    if (mid == 0 && s[mid] == t[i] && d[i] == 'L') {
      return true;
    }
    if (s[mid] == t[i]) {
      if (d[i] == 'L') {
        --mid;
      } else {
        ++mid;
      }
    }
  }
  return false;
}
bool is_ok2(int mid) {
  for (int i = 0; i < (q); ++i) {
    if (mid == n - 1 && s[mid] == t[i] && d[i] == 'R') {
      return true;
    }
    if (s[mid] == t[i]) {
      if (d[i] == 'L') {
        --mid;
      } else {
        ++mid;
      }
    }
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q >> s;
  for (int i = 0; i < (q); ++i) {
    cin >> t[i] >> d[i];
  }
  int lb1 = -1, ub1 = n + 1;
  while (ub1 - lb1 > 1) {
    int mid = (lb1 + ub1) / 2;
    if (is_ok1(mid)) {
      lb1 = mid;
    } else {
      ub1 = mid;
    }
  }
  int lb2 = -1, ub2 = n;
  while (ub2 - lb2 > 1) {
    int mid = (lb2 + ub2) / 2;
    if (is_ok2(mid)) {
      ub2 = mid;
    } else {
      lb2 = mid;
    }
  }
  cout << "lb1"
       << ": " << lb1 << '\n';
  cout << "ub1"
       << ": " << ub1 << '\n';
  cout << "lb2"
       << ": " << lb2 << '\n';
  cout << "ub2"
       << ": " << ub2 << '\n';
  cout << n - min(n, lb1 + 1 + n - ub2) << '\n';
  return 0;
}
