#include <bits/stdc++.h>
using namespace std;
bool isVowel(char c) {
  return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
bool prime[1000050];
void sieve() {
  fill(prime, prime + 1000050, 1);
  prime[0] = prime[1] = 0;
  for (int i = 2; i < 1000050; i++) {
    if (prime[i]) {
      for (int j = i * 2; j < 1000050; j += i) {
        prime[j] = 0;
      }
    }
  }
}
void mul(long long int a[2][2], long long int b[2][2]) {
  long long int p = a[0][0] * b[0][0] + a[0][1] * b[1][0];
  long long int q = a[0][0] * b[0][1] + a[0][1] * b[1][1];
  long long int r = a[1][0] * b[0][0] + a[1][1] * b[1][0];
  long long int s = a[1][0] * b[0][1] + a[1][1] * b[1][1];
  a[0][0] = p % 1000000007;
  a[0][1] = q % 1000000007;
  a[1][0] = r % 1000000007;
  a[1][1] = s % 1000000007;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  unordered_map<char, unordered_map<char, int>> back, nex;
  for (int i = 0; i < n; i++) {
    if (i) {
      back[s[i]][s[i - 1]]++;
    }
    if (i != n - 1) {
      nex[s[i]][s[i + 1]]++;
    }
  }
  unordered_map<char, int> final;
  for (char c : s) {
    final[c]++;
  }
  while (q--) {
    char a, b;
    cin >> a >> b;
    auto dict = (b == 'L' ? back[a] : nex[a]);
    if (final[a] == 0) {
      continue;
    }
    int just = 0;
    for (auto e : dict) {
      final[e.first] += e.second;
    }
    final[a] = 0;
  }
  int ans = 0;
  for (int i = 65; i <= 90; i++) {
    ans += final[(char)i];
  }
  cout << ans;
}
