class Dice
  attr_accessor :v, :h
  def initialize(pips)
    pips = pips.split.map(&:to_i)
    @v = [pips[0], pips[1], pips[5]]
    @h = [pips[3], pips[2], pips[4]]
  end

  def rotate(dir)
    tmp = @v[0]
    case dir
    when 'E'; @v[0] = @h[0]; @h[0] = @v[2]; @v[2] = @h[1]; @h[1] = tmp
    when 'W'; @v[0] = @h[1]; @h[1] = @v[2]; @v[2] = @h[0]; @h[0] = tmp
    when 'S'; @v[0] = @h[2]; @h[2] = @v[2]; @v[2] = @v[1]; @v[1] = tmp
    when 'N'; @v[0] = @v[1]; @v[1] = @v[2]; @v[2] = @h[2]; @h[2] = tmp
    end
  end

  def pip
    @v[0]
  end
end

d = Dice.new gets
gets.chomp.each_char do |c|
  d.rotate(c)
end
puts d.pip