class Dice
    attr_reader :top, :front, :right, :left, :back, :bottom

    def initialize(top, front, right, left, back, bottom)
        @top, @front, @right, @left, @back, @bottom \
            = top, front, right, left, back, bottom
    end

    def south
        @top, @front, @bottom, @back \
            = @back, @top, @front, @bottom
    end

    def north
        @top, @front, @bottom, @back \
            = @front, @bottom, @back, @top
    end

    def east
        @top, @right, @bottom, @left \
            = @left, @top, @right, @bottom
    end

    def west
        @top, @right, @bottom, @left \
            = @right, @bottom, @left, @top
    end
end

dice = Dice.new(*(gets.chomp.split.map(&:to_i)))

opary = gets.chomp.split(//)
opary.each do |op|
    case op
    when "S"
        dice.south
    when "N"
        dice.north
    when "E"
        dice.east
    when "W"
        dice.west
    end
end

puts dice.top