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

die = gets.split.map(&:to_i)

str = gets.chomp

while str != ""
d = str.slice!(0)

temp = Array.new(6)

case d

when "N"
for j in 1..6
temp[N[j-1]-1] = die[j-1]
end

when "S"
for j in 1..6
temp[S[j-1]-1] = die[j-1]
end

when "E"
for j in 1..6
temp[E[j-1]-1] = die[j-1]
end

when "W"
for j in 1..6
temp[W[j-1]-1] = die[j-1]
end
end

die = temp
end


puts die[0]







