def rotN(ht)
    tmp=ht['T']
    ht['N']=ht['T']
    ht['T']=ht['S']
    ht['S']=7-tmp
    return ht
end

def rotS(ht)
    tmp=ht['T']
    ht['S']=ht['T']
    ht['T']=ht['N']
    ht['N']=7-tmp
    return ht
end

def rotE(ht)
    tmp=ht['T']
    ht['E']=ht['T']
    ht['T']=ht['W']
    ht['W']=7-tmp
    return ht
end

def rotW(ht)
    tmp=ht['T']
    ht['W']=ht['T']
    ht['T']=ht['E']
    ht['E']=7-tmp
    return ht
end

mp=gets.split(' ').map(&:to_i)
rs=gets
lbl=Hash.new
mp.each_with_index do |x,i|
   lbl.store(i+1,x)
end
ht={'T'=>1,'S'=>2,'N'=>5,'W'=>4,'E'=>3}
rs.length.times do |i|
   case rs[i]
   when 'N' then ht=rotN(ht)
   when 'S' then ht=rotS(ht)
   when 'E' then ht=rotE(ht)
   when 'W' then ht=rotW(ht)
   end
end
p lbl[ht['T']]