<?php
	$str = explode(' ', fgets(STDIN));
	$ret = $Q = $str[0];
	$num = 0;
	$N = $str[1];
	$s['m'] = fgets(STDIN);
	$s['g'] = array_fill(0, $Q, 1);
	for($i=0;$i<$N; $i++) {
      $td[$i] = explode(' ', fgets(STDIN));
      $t = $td[$i][0];
      $d = $td[$i][1];
      for($j=0; $j<$Q; $j++) {
        if($t === $s['m'][$j]) {
          if(strpos($d, "L") !== false) {
            if($j > 0) {
              $s['g'][$j - 1] = $s['g'][$j - 1] + $s['g'][$j];
            }
            $s['g'][$j] = 0;
          }
          else if(strpos($d, "R") !== false) {
            if($j < $Q - 1) {
              $s['g'][$j + 1] = $s['g'][$j + 1] + $s['g'][$j];
            }
            $s['g'][$j] = 0;
          }
        }
      }
    }
	for($k=0; $k<$Q; $k++) {
      $num = $num + $s['g'][$k];
    }
	echo $num;
	

 ?>