class Dice
  attr_accessor :faces #メンバ変数を外部から参照可能に dice.faces

  def initialize(arr)
    @faces = arr
  end
  def roll(direction)
    case direction
    when "N"
      tmp = @faces[0]
      @faces[0] = @faces[1]
      @faces[1] = @faces[5]
      @faces[4] = @faces[5]
      @faces[5] = tmp
    when "S"
      tmp = @faces[0]
      @faces[0] = @faces[4]
      @faces[4] = @faces[5]
      @faces[5] = @faces[1]
      @faces[1] = tmp
    when "E"
      tmp = @faces[0]
      @faces[0] = @faces[3]
      @faces[3] = @faces[5]
      @faces[5] = @faces[2]
      @faces[2] = tmp
    when "W"
      tmp = @faces[0]
      @faces[0] = @faces[2]
      @faces[2] = @faces[5]
      @faces[5] = @faces[3]
      @faces[3] = tmp
    end
  end
end

face = gets.split.map { |e| e.to_i }
dice = Dice.new(face)
s = gets.chomp.split(//).map { |e| dice.roll(e) }

puts dice.faces[0]