#include <bits/stdtr1c++.h>
using namespace std;

char js[1000000];
bool as[1000000];

int main() {
  ios::sync_with_stdio(0);
  int s, a; cin >> s >> a;
  for (int i = 0; i < s; i++) {
    cin >> js[i];
    if (js[i] == 'L')
      js[i] = 3;
    else if (js[i] == 'M')
      js[i] = 2;
    else if (js[i] == 'S')
      js[i] = 1;
  }
  int S = 0;
  for (int i = 0; i < a; i++) {
    char j; int x; cin >> j >> x;
    x--;
    if (j == 'L')
      j = 3;
    else if (j == 'M')
      j = 2;
    else if (j == 'S')
      j = 1;
    if (x >= s)
      continue;
    char k = js[x];
    if (k == 'x')
      continue;
    //cout << i << " " << x << " " << (int)j << " " << (int)k << endl;
    if (j <= k) {
      S++;
      js[x] = 'x';
    }
  }
  cout << S << "\n";
  return 0;
}