import numpy as np
n, q  = map(int, input().split())
s = input()
class people :
    def __init__(self,num, string):
        self.num = num
        self.string = string
    def move(self,R_or_L, s):
        if R_or_L == 'L':
            self.num -=1
            if self.num <0 :
                return False
            else :
                self.string = s[self.num]
                return self
        else :
            self.num +=1
            try :
                self.string = s[self.num]
                return self
            except:
                return False
              
              
p_list = [people(i,j) for i,j in zip(range(n), s)]
if q < n/2 :
  p_list = np.array(p_list[:q]+p_list[n-q:])
else :
  p_list = np.array(p_list)

for i in range(q):
  a,b = input().split()
  p_list = np.array( p_list)[np.where([p.move(b, s) if p.string == a else p for p in p_list])[0]]
  
print(len(p_list))