<?php

$line = trim( fgets(STDIN) );
$temp = explode(" ", $line);
$N = $temp[0];
$Q = $temp[1];

$line = trim( fgets(STDIN) );
$sLen = strlen($line);
$s = str_split($line);

$t = array();
$d = array();

for ( $i = 0; $i < $Q; $i++ ) {
    $line = trim( fgets(STDIN) );
    $temp = explode(" ", $line);
    $t[] = $temp[0];
    $d[] = $temp[1];
}

$countLmax = 0;
$countRmax = 0;
$countLtemp = 0;
$countRtemp = 0;

for ( $i = $Q - 1; $i >= 0; $i-- ) {
    if ( $t[$i] == $s[$countLtemp] && $d[$i] == 'L' ) {
        $countLtemp = $countLtemp + 1;
    } else if ( $countLtemp > 0 && $t[$i] == $s[$countLtemp - 1] && $d[$i] == 'R' ) {
        $countLmax = max( $countLmax, $countLtemp );
        $countLtemp = 0;
    }

    if ( $t[$i] == $s[$sLen - 1 - $countRtemp] && $d[$i] == 'R' ) {
        $countRtemp = $countRtemp + 1;
    } else if ( $countRtemp > 0 && $t[$i] == $s[$sLen - 1 - ($countRtemp-1)] && $d[$i] == 'L' ) {
        $countRmax = max( $countRmax, $countRtemp );
        $countRtemp = 0;
    }
}

$countLmax = max( $countLmax, $countLtemp );
$countRmax = max( $countRmax, $countRtemp );

echo max($N - $countLmax - $countRmax,  0);
