# Dice for AOJ
class Dice
  def initialize(input)
    @t, @s, @e, @w, @n, @b = input
  end

  def roll_e
    tmp = @e
    @e = @t
    @t = @w
    @w = @b
    @b = tmp
  end

  def roll_n
    tmp = @n
    @n = @t
    @t = @s
    @s = @b
    @b = tmp
  end

  def roll_w
    tmp = @w
    @w = @t
    @t = @e
    @e = @b
    @b = tmp
  end

  def roll_s
    tmp = @s
    @s = @t
    @t = @n
    @n = @b
    @b = tmp
  end

  def print_t
    puts @t
  end
end

d = gets.split.map(&:to_i)
dice = Dice.new(d)
cmd = gets.chomp
cmd.length.times do |i|
  c = cmd[i]
  case c
  when 'E'
    dice.roll_e
  when 'N'
    dice.roll_n
  when 'W'
    dice.roll_w
  when 'S'
    dice.roll_s
  end
end
dice.print_t

