#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<pair<char, int>> v;
  map<char, vector<int>> m;
  v.push_back(pair<char, int>{'#', 0});
  for (int i = 0; i < n; i++) {
    char c = s[i];
    v.push_back(pair<char, int>{c, 1});
    m[c].push_back(i);
  }
  v.push_back(pair<char, int>{'#', 0});
  for (int i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    for (auto j : m[t]) {
      if (d == 'L') {
        v[j].second += v[j + 1].second;
        v[j + 1].second = 0;
      } else {
        v[j + 2].second += v[j + 1].second;
        v[j + 1].second = 0;
      }
    }
  }
  v.erase(v.begin());
  v.erase(v.end());
  int sum = 0;
  for (auto &&p : v) {
    sum += p.second;
  }
  cout << sum << "\n";
}
