#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YN(bool b) { cout << (b ? "Yes" : "No") << endl; }
int main(void) {
  long long int n, q, k, i, j;
  string s;
  cin >> n >> q;
  cin >> s;
  map<char, list<int>> charPos;
  int currentPos = 0;
  for (auto ch : s) {
    if (charPos.count(ch) == 0) {
      list<int> chPos;
      charPos[ch] = chPos;
    }
    charPos[ch].push_back(currentPos);
    currentPos++;
  }
  int grid[n];
  for (int i = 0; i < (n); ++i) {
    grid[i] = 1;
  }
  char t, d;
  for (int i = 0; i < (q); ++i) {
    cin >> t >> d;
    int count;
    for (auto pos : charPos[t]) {
      count = grid[pos];
      grid[pos] = 0;
      if (d == 'L' && pos > 0) {
        grid[pos - 1] += count;
      } else if (d == 'R' && pos < n - 1) {
        grid[pos + 1] += count;
      }
    }
  }
  int total = 0;
  for (auto value : grid) {
    total += value;
  }
  cout << total << endl;
  return 0;
}
