#include <iostream>

using namespace std;

int arr[1000000 + 5] = { 0 };
int main()
{
	int j, p;
	cin >> j >> p;
	for (int i = 0; i < j; i++)
	{
		char c;
		cin >> c;
		if (c == 'S')
			arr[i] = 1;
		else if (c == 'M')
			arr[i] = 2;
		else
			arr[i] = 3;
	}
	int count = 0;
	for (int i = 0; i < p; i++)
	{
		char c;
		int num;
		cin >> c >> num;
		num--;
		if (arr[num] == 0)
			continue;
		else
		{
			if (c == 'L')
			{
				if (arr[num] < 3)
					continue;
			}
			else if (c == 'M')
			{
				if (arr[num] < 2)
					continue;
			}
			arr[num] = 0;
			count++;
		}
	}
	cout << count << endl;
	return 0;
}