#include <bits/stdc++.h>
constexpr int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  string t;
  vi d(q);
  for (ll i = 0; i < ll(q); ++i) {
    char a, b;
    cin >> a >> b;
    t += a;
    if (b == 'R')
      d[i] = 1;
    else
      d[i] = -1;
  }
  auto check = [&](int p) {
    char c = s[p];
    int pos = p;
    for (ll i = 0; i < ll(q); ++i) {
      if (t[i] == c) {
        pos += d[i];
        if (pos == -1) return -1;
        if (pos == n) return 1;
        c = s[pos];
      }
    }
    return 0;
  };
  int a = check(0), b = check(n - 1);
  if (a == 0 && b == 0) {
    cout << n << endl;
  } else if (a == 0) {
    int l = 0, r = n;
    while (r - l > 1) {
      int mid = (r + l) / 2;
      if (check(mid) == 0)
        l = mid;
      else
        r = mid;
    }
    cout << n - l - 1 << endl;
  } else if (b == 0) {
    int l = 0, r = n;
    while (r - l > 1) {
      int mid = (r + l) / 2;
      if (check(mid) == 0)
        r = mid;
      else
        l = mid;
    }
    cout << n - r << endl;
  } else {
    int l = 0, r = n;
    int m = -1;
    while (r - l > 1) {
      int mid = (r + l) / 2;
      int c = check(mid);
      if (c == 0) {
        m = mid;
        break;
      } else if (c == 1) {
        r = mid;
      } else {
        l = mid;
      }
    }
    assert(m != -1);
    int res = n;
    l = 0, r = m;
    while (r - l > 1) {
      int mid = (r + l) / 2;
      int c = check(mid);
      if (c == 0)
        r = mid;
      else
        l = mid;
    }
    res -= r;
    l = m, r = n;
    while (r - l > 1) {
      int mid = (r + l) / 2;
      int c = check(mid);
      if (c == 0)
        l = mid;
      else
        r = mid;
    }
    res -= n - r;
    cout << res << endl;
  }
}
