m, n = map(int,input().split())
s = input()
dp = [1]*m
#print(s)
for i in range(n):
  t, d = map(str,input().split())
  for j in range(m):
    if s[j] == t and j == 0:
      if d == 'L':
        dp[j] = 0
      elif d == 'R':
        dp[j+1] += dp[j]
        dp[j] = 0
        #print(dp)
    elif s[j] == t and j == m-1:
      if d == 'R':
        dp[j] = 0
      elif d == 'L':
        dp[j-1] += dp[j]
        dp[j] = 0
        #print(dp)
    elif s[j] == t:
      if d == 'L':
        dp[j-1] += dp[j]
        dp[j] = 0
        #print(dp)
      elif d == 'R':
        dp[j+1] += dp[j]
        dp[j] = 0
        #print(dp)
#print(dp)
print(sum(dp))