n = gets.chomp.split.map(&:to_i)
d = gets.chomp.to_s

d.chars{ |i|
  if i == "S"
    n[0],n[1],n[4],n[5] = n[4],n[0],n[5],n[1]
  elsif i == "E"
    n[0],n[2],n[3],n[5] = n[3],n[0],n[5],n[2]
  elsif i == "W"
    n[0],n[2],n[3],n[5] = n[2],n[5],n[0],n[3]
  else
    n[0],n[1],n[4],n[5] = n[1],n[5],n[0],n[4]
  end
}
puts n[0]