from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
n = ip()                                     #入力整数1つ
#n,q= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
name = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
nl = [name[i] for i in range(26)]
l = [0 for i in range(26)]
valid = [0 for i in range(26)]
for i in range(n):
    p = name.index(a[i])
    valid[i] = 1
    l[p]+=1
p = 25
leftmost = 0
rightmost = 25
while valid[leftmost]==0:leftmost+=1
while valid[rightmost]==0:rightmost-=1

while l[p]==0:
    l.pop()
    p-=1
for loop in range(q):
    sel,move = input().split()
    alpha = name.index(sel)
    sub = l[alpha]
    if sub:
        l[alpha] = 0
        if move == 'R':
            alpha += 1
            while valid[alpha] == 0:
                alpha += 1
                if alpha > rightmost:break
            if alpha<=rightmost:
                l[alpha]+=sub
        else:
            alpha-= 1
            while valid[alpha] == 0:
                alpha -= 1
                if alpha < leftmost: break
            if alpha >= leftmost:
                l[alpha] += sub
print(sum(l))