class Dice
  def initialize(n)
    @n = n
  end
  #     ^N
  #    n[0]:top
  # [3] [1] [2] [4]
  #     [5]:bottom
  #     vS
  attr_reader :n

  def rotate(d)
    case d
    when "N"
      @n = [@n[1], @n[5], @n[2], @n[3], @n[0], @n[4]]
    when "S"
      @n = [@n[4], @n[0], @n[2], @n[3], @n[5], @n[1]]
    when "E"
      @n = [@n[3], @n[1], @n[0], @n[5], @n[4], @n[2]]
    when "W"
      @n = [@n[2], @n[1], @n[5], @n[0], @n[4], @n[3]]
    else
      raise
    end
  end
end

d=Dice.new(gets.split.map(&:to_i))
gets.chomp.chars{|c|d.rotate(c)}
p d.n[0]


