<?php

$input = explode(' ', trim(fgets(STDIN)));
$n = (int)$input[0];
$q = (int)$input[1];

$s = trim(fgets(STDIN));

$qs = [];
for ($j=1; $j <= $q; $j++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$t = $input[0];
	$d = $input[1];
	$qs[] = [
		't' => $t,
		'd' => $d,
	];
}

$left = 0;
$right = $n;
$l_idx = -1;
while ($left < $right) {
	$mid = (int)floor(($left+$right)/2);
	if (toLeft($mid)) {
		$left = $mid + 1;
		$l_idx = max($l_idx, $mid);
	}else{
		$right = $mid;
	}
}
$left = 0;
$right = $n;
$r_idx = $n;
while ($left < $right) {
	$mid = (int)floor(($left+$right)/2);
	if (toRight($mid)) {
		$right = $mid;
		$r_idx = min($r_idx, $mid);
	}else{
		$left = $mid + 1;
	}
}
// echo 'l: ' . $l_idx . PHP_EOL;
// echo 'r: ' . $r_idx . PHP_EOL;
if ($l_idx > $r_idx) {
	echo 0;
}else{
	echo $n - ($l_idx+1 + ($n - $r_idx));
}




function toLeft($p){
	global $qs;
	global $s;
	global $n;
	$res = false;
	for ($i=0; $i < count($qs); $i++) { 
		$tmp_s = $s[$p];
		$q = $qs[$i];
		if ($q['t'] === $tmp_s) {
			if ($q['d'] === 'L') {
				--$p;
			}else{
				++$p;
			}
		}
		if ($p < 0 || $p > $n-1) {
			if ($p < 0) {
				$res = true;
			}
			break;
		}
	}
	return $res;
}
function toRight($p){
	global $qs;
	global $s;
	global $n;
	$res = false;
	for ($i=0; $i < count($qs); $i++) { 
		$tmp_s = $s[$p];
		$q = $qs[$i];
		if ($q['t'] === $tmp_s) {
			if ($q['d'] === 'L') {
				--$p;
			}else{
				++$p;
			}
		}
		if ($p < 0 || $p > $n-1) {
			if ($p > $n-1) {
				$res = true;
			}
			break;
		}
	}
	return $res;
}