#include <bits/stdc++.h>
using namespace std;
double e_time(void) {
  static struct timeval now;
  gettimeofday(&now, NULL);
  return (double)(now.tv_sec + now.tv_usec / 1000000.0);
}
template <class T>
void vp(T& a, int p) {
  for (int i = 0; i < p; i++) cout << a[i] << " ";
  cout << endl;
}
template <class T>
T ceilUp(const T& a, const T& b) {
  return (a + b - 1) / b;
}
const long long mod = 1000000009;
inline long long modadd(long long a, long long b) {
  a %= mod;
  b %= mod;
  return (a + b) % mod;
}
inline long long modsub(long long a, long long b) {
  a %= mod;
  b %= mod;
  a -= b;
  a %= mod;
  if (a < 0) a += mod;
  return a;
}
inline long long modmul(long long a, long long b) {
  a %= mod;
  b %= mod;
  return (a * b) % mod;
}
inline long long modeq(long long a, long long b, long long m) {
  a = (a % m + m) % m;
  b = (b % m + m) % m;
  return a == b;
}
long long mypow(long long n, long long p) {
  if (p == 0) return 1;
  if (p == 1) return n;
  long long ret = mypow(n, p / 2);
  ret = ret * ret;
  if (p & 1) ret = ret * n;
  return ret;
}
bool check(int n, const string& in, vector<char>& pos, vector<int>& order,
           bool isCountLeft, int my_pos) {
  const int q = pos.size();
  for (int i = 0; i < q; i++) {
    if (in[my_pos] == pos[i]) {
      my_pos += order[i];
    }
    if (my_pos < 0 || my_pos >= n) break;
  }
  if (isCountLeft && my_pos < 0) return true;
  if (!isCountLeft && my_pos >= n) return true;
  return false;
}
int solve(int n, const string& in, vector<char>& pos, vector<int>& order,
          bool isCountLeft) {
  int l = 0, r = n;
  if (isCountLeft && !check(n, in, pos, order, isCountLeft, 0)) {
    return 0;
  } else if (!isCountLeft && !check(n, in, pos, order, isCountLeft, n - 1)) {
    return 0;
  }
  if (!isCountLeft) {
    l = -1;
    r = n - 1;
  }
  for (int i = 0; i < 50; i++) {
    int mid = (l + r) / 2;
    bool isGone = check(n, in, pos, order, isCountLeft, mid);
    if (isGone) {
      if (isCountLeft) {
        l = mid;
      } else {
        r = mid;
      }
    } else {
      if (isCountLeft) {
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
  }
  if (isCountLeft) {
    return l + 1;
  } else {
    return n - r;
  }
}
int main() {
  int n, q;
  cin >> n >> q;
  string in;
  cin >> in;
  vector<char> pos(q);
  vector<int> order(q);
  for (int i = 0; i < q; i++) {
    cin >> pos[i];
    char tmp;
    cin >> tmp;
    if (tmp == 'L')
      order[i] = -1;
    else if (tmp == 'R')
      order[i] = +1;
    else
      assert(0);
  }
  int goneLeft = solve(n, in, pos, order, true);
  int goneRight = solve(n, in, pos, order, false);
  cout << n - goneLeft - goneRight << endl;
  return 0;
}
