#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector<int> v[100];
int a[maxn];
char c[maxn];
vector<int> v_i[5];
int main() {
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    int num = c[i] - 'A';
    v[num].push_back(i);
    a[i] = 1;
  }
  char x, y;
  while (q--) {
    cin >> x >> y;
    int num1 = x - 'A';
    if (y == 'L') {
      for (int i = 0; i < v[num1].size(); i++) {
        int j = v[num1][i];
        a[j - 1] += a[j];
        if (j - 1 == 0) a[j - 1] == 0;
        a[j] = 0;
      }
    } else {
      for (int i = 0; i < v[num1].size(); i++) {
        if (i == n) a[i] = 0;
        int j = v[num1][i];
        a[j + 1] += a[j];
        if (j == n) a[j + 1] = 0;
        a[j] = 0;
      }
    }
  }
  long long sum1 = 0;
  for (int i = 1; i <= n; i++) {
    sum1 += a[i];
  }
  cout << sum1 << endl;
  return 0;
}
