class Dice
  def initialize(side)
    @side = side;
  end
  
  def get_top
    return @side[@top];
  end
  
  def get_top
    return @side[0]
  end
  
  def move_s
    @side[0], @side[1], @side[5], @side[4] = @side[4], @side[0], @side[1], @side[5];
  end
  
  def move_n
    @side[0], @side[1], @side[5], @side[4] = @side[1], @side[5], @side[4], @side[0];
  end
  
  def move_e
    @side[0], @side[2], @side[5], @side[3] = @side[3], @side[0], @side[2], @side[5];
  end
  
  def move_w
    @side[0], @side[2], @side[5], @side[3] = @side[2], @side[5], @side[3], @side[0];
  end
end

dice = Dice.new(gets.split(" ").map(&:to_i));
a = gets.chomp.split("");

for s in a do
  if s == "S" then
    dice.move_s;
  elsif s == "N" then
    dice.move_n;
  elsif s == "E" then
    dice.move_e;
  elsif s == "W" then
    dice.move_w;
  end
end

puts dice.get_top;