#include <bits/stdc++.h>
#pragma GCC optimize("O3")
long mod(long a) {
  long long c = a % (long long)(1e9 + 7);
  if (c >= 0) return c;
  return c + (long long)(1e9 + 7);
}
using namespace std;
bool prime_(int n) {
  if (n == 1) {
    return false;
  } else if (n == 2) {
    return true;
  } else {
    for (int i = 2; i <= sqrt(n); i++) {
      if (n % i == 0) {
        return false;
      }
    }
    return true;
  }
}
long long gcd_(long long a, long long b) {
  if (a < b) {
    swap(a, b);
  }
  if (a % b == 0) {
    return b;
  } else {
    return gcd_(b, a % b);
  }
}
long long lcm_(long long x, long long y) { return (x / gcd_(x, y)) * y; }
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[q], d[q];
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  int l = 0, r = n;
  while (r - l > 1) {
    int m = (l + r) / 2;
    int now = m;
    for (int i = 0; i < n; i++) {
      if (now == 0 || now == n + 1) break;
      if (s[now - 1] == t[i]) {
        if (d[i] == 'L') {
          now--;
        } else {
          now++;
        }
      } else {
        continue;
      }
    }
    if (now == 0) {
      l = m;
    } else {
      r = m;
    }
  }
  int left = r;
  l = 1, r = n + 1;
  while (r - l > 1) {
    int m = (l + r) / 2;
    int now = m;
    for (int i = 0; i < n; i++) {
      if (now == 0 || now == n + 1) break;
      if (s[now - 1] == t[i]) {
        if (d[i] == 'L') {
          now--;
        } else {
          now++;
        }
      } else {
        continue;
      }
    }
    if (now == n + 1) {
      r = m;
    } else {
      l = m;
    }
  }
  int right = l;
  int ans = right - left + 1;
  cout << ans << endl;
  return 0;
}
