#include <bits/stdc++.h>
using namespace std;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, -1, 0, 1};
int dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int INF = 1e9;
const int MAX_V = 1e6 + 1;
const long long mod = 1000000007;
map<char, vector<int>> mp;
int memo[100001];
int N, Q;
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> Q >> s;
  for (int i = 0; i < (int)(N); i++) {
    memo[i] = 1;
    vector<int> vv;
    mp[s[i]] = vv;
  }
  for (int i = 0; i < (int)(N); i++) {
    vector<int> vv = mp[s[i]];
    vv.push_back(i);
    mp[s[i]] = vv;
  }
  for (int i = 0; i < (int)(Q); i++) {
    char a, b;
    cin >> a >> b;
    int sl = mp[a].size();
    if (b == 'L') {
      for (int j = 0; j < (int)(sl); j++) {
        int sj = mp[a][j];
        int c = memo[sj];
        memo[sj] = 0;
        if (sj != 0) memo[sj - 1] += c;
      }
    } else {
      for (int j = sl; j--; 0 < j) {
        int sj = mp[a][j];
        int c = memo[sj];
        memo[sj] = 0;
        if (sj != N - 1) memo[sj + 1] += c;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (int)(N); i++) {
    ans += memo[i];
  }
  cout << ans << endl;
}
