#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const long long int MAX = 1e9 + 7;
void array_show(int *array, int array_n, char middle = ' ') {
  for (int i = 0; i < array_n; i++)
    printf("%d%c", array[i], (i != array_n - 1 ? middle : '\n'));
}
void array_show(long long int *array, int array_n, char middle = ' ') {
  for (int i = 0; i < array_n; i++)
    printf("%lld%c", array[i], (i != array_n - 1 ? middle : '\n'));
}
void print_YES_NO(bool answer) { cout << (answer ? "YES" : "NO") << endl; }
void print_Yes_No(bool answer) { cout << (answer ? "Yes" : "No") << endl; }
void print_POSSIBLE_IMPOSSIBLE(bool answer) {
  cout << (answer ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}
char ca[200005];
vector<char> v1, v2;
int main() {
  int n, m;
  int i, j, k;
  int a, b, c;
  char x, y, z;
  cin >> n >> m;
  cin >> ca;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    if (y == 'L')
      v1.push_back(x);
    else
      v2.push_back(x);
  }
  for (i = v1.size() - 1, a = 0; i >= 0; i--) {
    if (v1[i] == ca[a]) a++;
  }
  for (i = v2.size() - 1, b = 0; i >= 0; i--) {
    if (v2[i] == ca[n - b - 1]) b++;
  }
  cout << n - a - b << endl;
  return 0;
}
