#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<pair<int,char>>pos(n);
	rep(i, n) {
		pos[i].F = i;
		pos[i].second = s[i];
	}
	int count = 0;
	rep(i, q) {
		char t, d;
		cin >> t >> d;
		int move = 0;
		if (d == 'R') {
			move = 1;
		}
		else {
			move = -1;
		}
		rep(j, n) {
			if (pos[j].second == t) {
				pos[j].first += move;
				if (pos[j].first <= -1 or pos[j].first >= n) {
					pos[j].second = '0';
					count++;
				}
				else {
					pos[j].second = s[pos[j].first];
				}
			}
		}
	}

	cout << n - count << endl;
}
