class Dice
  N = [0, 2, 6, 6, 2, 1, 5]
  E = [0, 4, 4, 3, 6, 4, 4]
  W = [0, 3, 3, 5, 1, 3, 3]
  S = [0, 5, 1, 1, 5, 6, 2]

  def initialize(dice)
    @dice = dice
    @top  = 1
  end

  def move(direction)
    case direction
    when 'N' then @top = N[@top]
    when 'E' then @top = E[@top]
    when 'W' then @top = W[@top]
    when 'S' then @top = S[@top]
    end
    @top
  end

  def top
    @dice[@top-1]
  end
end

corts = gets.chomp.split
direction = gets.chomp.chars

dice = Dice.new(corts)
direction.each { |c| dice.move(c) }
puts dice.top