#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, Q;
  string s;
  cin >> N >> Q;
  long long new_map = 1;
  map<char, int> golem;
  vector<vector<long long>> g_map(100);
  map<long long, long long> count;
  for (int i = 0; i < 100; ++i) {
    count[i] = 1;
  }
  for (long long i = 0; i < N; ++i) {
    char buf;
    cin >> buf;
    if (golem[buf] == 0) {
      golem[buf] = new_map;
      ++new_map;
    }
    g_map[golem[buf]].push_back(i + 1);
  }
  for (long long i = 0; i < Q; ++i) {
    char buf1, buf2;
    cin >> buf1 >> buf2;
    int ho;
    if (buf2 == 'R') {
      for (long long j = g_map[golem[buf1]].size() - 1; j >= 0; --j) {
        if (count[g_map[golem[buf1]][j]] > 0) {
          count[g_map[golem[buf1]][j] + 1] += count[g_map[golem[buf1]][j]];
          count[g_map[golem[buf1]][j]] = 0;
        }
      }
    } else if (buf2 == 'L') {
      for (long long j = 0; j < g_map[golem[buf1]].size(); ++j) {
        if (count[g_map[golem[buf1]][j]] > 0) {
          count[g_map[golem[buf1]][j] - 1] += count[g_map[golem[buf1]][j]];
          count[g_map[golem[buf1]][j]] = 0;
        }
      }
    }
  }
  long long counter = 0;
  for (long long i = 1; i <= N; ++i) {
    counter += count[i];
  }
  cout << counter << endl;
  return 0;
}
