import sys



dice = [int(i) for i in sys.stdin.readline().split()]

command = sys.stdin.readline().strip()

for c in command:

    if c == "N":

        dice = (dice[1], dice[5], dice[2], dice[3], dice[0], dice[4])

    elif c == "S":

        dice = (dice[4], dice[0], dice[2], dice[3], dice[5], dice[1])

    elif c == "W":

        dice = (dice[2], dice[1], dice[5], dice[0], dice[4], dice[3])

    elif c == "E":

        dice = (dice[3], dice[1], dice[0], dice[5], dice[4], dice[2])

print((dice[0]))
import sys



class Dice(object):

    def __init__(self, dice):

        self.__dice = dice



    def roll_north(self):

        self.__dice = (self.__dice[1], self.__dice[5], self.__dice[2],

                       self.__dice[3], self.__dice[0], self.__dice[4])



    def roll_south(self):

        self.__dice = (self.__dice[4], self.__dice[0], self.__dice[2],

                       self.__dice[3], self.__dice[5], self.__dice[1])



    def roll_west(self):

        self.__dice = (self.__dice[2], self.__dice[1], self.__dice[5],

                       self.__dice[0], self.__dice[4], self.__dice[3])



    def roll_east(self):

        self.__dice = (self.__dice[3], self.__dice[1], self.__dice[0],

                       self.__dice[5], self.__dice[4], self.__dice[2])



    def number(self, face_id):

        return self.__dice[face_id - 1]





dice = Dice([int(i) for i in sys.stdin.readline().split()])

command = sys.stdin.readline().strip()

for c in command:

    if c == "N":

        dice.roll_north()

    elif c == "S":

        dice.roll_south()

    elif c == "W":

        dice.roll_west()

    elif c == "E":

        dice.roll_east()

print((dice.number(1)))
import sys

dice = [int(i) for i in sys.stdin.readline().split()]
command = sys.stdin.readline().strip()
for c in command:
    if c == "N":
        dice = (dice[1], dice[5], dice[2], dice[3], dice[0], dice[4])
    elif c == "S":
        dice = (dice[4], dice[0], dice[2], dice[3], dice[5], dice[1])
    elif c == "W":
        dice = (dice[2], dice[1], dice[5], dice[0], dice[4], dice[3])
    elif c == "E":
        dice = (dice[3], dice[1], dice[0], dice[5], dice[4], dice[2])
print((dice[0]))

import sys


class Dice(object):
    def __init__(self, dice):
        self.__dice = dice

    def roll_north(self):
        self.__dice = (
            self.__dice[1],
            self.__dice[5],
            self.__dice[2],
            self.__dice[3],
            self.__dice[0],
            self.__dice[4],
        )

    def roll_south(self):
        self.__dice = (
            self.__dice[4],
            self.__dice[0],
            self.__dice[2],
            self.__dice[3],
            self.__dice[5],
            self.__dice[1],
        )

    def roll_west(self):
        self.__dice = (
            self.__dice[2],
            self.__dice[1],
            self.__dice[5],
            self.__dice[0],
            self.__dice[4],
            self.__dice[3],
        )

    def roll_east(self):
        self.__dice = (
            self.__dice[3],
            self.__dice[1],
            self.__dice[0],
            self.__dice[5],
            self.__dice[4],
            self.__dice[2],
        )

    def number(self, face_id):
        return self.__dice[face_id - 1]


dice = Dice([int(i) for i in sys.stdin.readline().split()])
command = sys.stdin.readline().strip()
for c in command:
    if c == "N":
        dice.roll_north()
    elif c == "S":
        dice.roll_south()
    elif c == "W":
        dice.roll_west()
    elif c == "E":
        dice.roll_east()
print((dice.number(1)))

-dice = [int(i) for i in sys.stdin.readline().split()] + +class Dice(object): +    def __init__(self, dice): +        self.__dice = dice + +    def roll_north(self): +        self.__dice = ( +            self.__dice[1], +            self.__dice[5], +            self.__dice[2], +            self.__dice[3], +            self.__dice[0], +            self.__dice[4], +        ) + +    def roll_south(self): +        self.__dice = ( +            self.__dice[4], +            self.__dice[0], +            self.__dice[2], +            self.__dice[3], +            self.__dice[5], +            self.__dice[1], +        ) + +    def roll_west(self): +        self.__dice = ( +            self.__dice[2], +            self.__dice[1], +            self.__dice[5], +            self.__dice[0], +            self.__dice[4], +            self.__dice[3], +        ) + +    def roll_east(self): +        self.__dice = ( +            self.__dice[3], +            self.__dice[1], +            self.__dice[0], +            self.__dice[5], +            self.__dice[4], +            self.__dice[2], +        ) + +    def number(self, face_id): +        return self.__dice[face_id - 1] + + +dice = Dice([int(i) for i in sys.stdin.readline().split()]) -        dice = (dice[1], dice[5], dice[2], dice[3], dice[0], dice[4]) +        dice.roll_north() -        dice = (dice[4], dice[0], dice[2], dice[3], dice[5], dice[1]) +        dice.roll_south() -        dice = (dice[2], dice[1], dice[5], dice[0], dice[4], dice[3]) +        dice.roll_west() -        dice = (dice[3], dice[1], dice[0], dice[5], dice[4], dice[2]) -print((dice[0])) +        dice.roll_east() +print((dice.number(1)))