class Dice

  def initialize(dice)
    @top  = dice[0]
    @side   = [ dice[4], dice[2], dice[1], dice[3] ]
    @bottom = dice[5]
  end

  def print_upper(action)
    action.chars do |str|
      b = @bottom
      u = @top
      case str
      when "N"
        @top   = @side[2]
        @bottom  = @side[0]
        @side[2] = b
        @side[0] = u
      when "E"
        @top   = @side[3]
        @bottom  = @side[1]
        @side[3] = b
        @side[1] = u
      when "S"
        @top   = @side[0]
        @bottom  = @side[2]
        @side[0] = b
        @side[2] = u
      when "W"
        @top   = @side[1]
        @bottom  = @side[3]
        @side[1] = b
        @side[3] = u
      end
    end
    puts @top
  end
end

d = Dice.new(gets.split.map(&:to_i))
d.print_upper(gets.chomp)