#include <bits/stdc++.h>
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
template <class T>
void view(T e) {
  cout << e << endl;
}
template <class T>
void view(const vector<T> &v) {
  for (const auto &e : v) {
    cout << e << " ";
  }
  cout << endl;
}
template <class T>
void view(const vector<vector<T>> &vv) {
  for (const auto &v : vv) {
    view(v);
  }
}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int, int>;
const int inf = 1e9 + 10;
const ll inf_l = 1e18;
const int MAX = 1e5;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vint data(n, 1);
  int ans = n;
  for (int i = 0; i < (int)(q); i++) {
    char t, d;
    cin >> t >> d;
    for (int j = 0; j < (int)(n); j++) {
      if (s[j] == t) {
        if (d == 'L') {
          if (j - 1 < 0)
            ans -= data[j];
          else
            data[j - 1] += data[j];
        } else {
          if (j + 1 >= n)
            ans -= data[j];
          else
            data[j + 1] += data[j];
        }
        data[j] = 0;
      }
    }
  }
  cout << ans << endl;
}
