#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-9;
const long long INF = 10e17;
double equal(double a, double b) { return fabs(a - b) < DBL_EPSILON; }
std::istream &operator>>(std::istream &in, set<int> &o) {
  int a;
  in >> a;
  o.insert(a);
  return in;
}
std::istream &operator>>(std::istream &in, queue<int> &o) {
  long long a;
  in >> a;
  o.push(a);
  return in;
}
bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> g(n, 1);
  for (int _ = 0; _ < (q); ++_) {
    char c, d;
    cin >> c >> d;
    for (int i = 0; i < (n); ++i) {
      if (s[i] != c) continue;
      if (d == 'R') {
        if (i + 1 < n) g[i + 1] += g[i];
        g[i] = 0;
      } else {
        if (i - 1 >= 0) g[i - 1] += g[i];
        g[i] = 0;
      }
    }
  }
  long long sum = accumulate(g.begin(), g.end(), 0ll);
  cout << sum << endl;
}
