#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, ans = 0;
  cin >> n >> q;
  int a[n];
  int b[51][n + 1];
  for (int i = 0; i < 51; i++)
    for (int j = 0; j < n + 1; j++) {
      b[i][j] = -1;
    }
  for (int i = 0; i < n; i++) a[i] = 1;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    for (int j = 0; j < n; j++) {
      if (b[c - 'A'][j] != -1) {
        continue;
      } else {
        b[c - 'A'][j] = i;
        break;
      }
    }
  }
  for (int i = 0; i < q; i++) {
    int cnt;
    char comA, comB;
    cin >> comA >> comB;
    cnt = 0;
    while (1) {
      if (b[comA - 'A'][cnt] == -1)
        break;
      else {
        if (comB == 'R') {
          if (b[comA - 'A'][cnt] == n - 1) {
            ans += a[n - 1];
            a[n - 1] = 0;
          } else {
            a[b[comA - 'A'][cnt] + 1] += a[b[comA - 'A'][cnt]];
            a[b[comA - 'A'][cnt]] = 0;
          }
        }
        if (comB == 'L') {
          if (b[comA - 'A'][cnt] == 0) {
            ans += a[0];
            a[0] = 0;
          } else {
            a[b[comA - 'A'][cnt] - 1] += a[b[comA - 'A'][cnt]];
            a[b[comA - 'A'][cnt]] = 0;
          }
        }
      }
      cnt++;
    }
  }
  cout << n - ans;
  return 0;
}
