class Dice:

    def __init__(self, face_vals):

        self.faces = dict(list(zip(['top', 'south', 'east',

                               'west', 'north', 'bottom'], face_vals)))



    def roll(self, direction):

        if direction == 'N':

            self.faces['top'], self.faces['south'], self.faces['bottom'], \

            self.faces['north'] = self.faces['south'], self.faces['bottom'], \

            self.faces['north'], self.faces['top']

        elif direction == 'S':

            self.faces['top'], self.faces['south'], self.faces['bottom'], \

            self.faces['north'] = self.faces['north'], self.faces['top'], \

            self.faces['south'], self.faces['bottom']

        elif direction == 'E':

            self.faces['top'], self.faces['east'], self.faces['bottom'], \

            self.faces['west'] = self.faces['west'], self.faces['top'], \

            self.faces['east'], self.faces['bottom']

        else:

            self.faces['top'], self.faces['east'], self.faces['bottom'], \

            self.faces['west'] = self.faces['east'], self.faces['bottom'], \

            self.faces['west'], self.faces['top']





face_vals = input().split()



dice = Dice(face_vals)



for i in eval(input()):

    dice.roll(i)



print((dice.faces['top']))
class Dice:

    def __init__(self, face_vals):

        self.faces = dict(list(zip(['top', 'front', 'right',

                               'left', 'back', 'bottom'], face_vals)))



    def roll(self, direction):

        if direction == 'N':

            self.faces['top'], self.faces['front'], self.faces['bottom'], \

            self.faces['back'] = self.faces['front'], self.faces['bottom'], \

            self.faces['back'], self.faces['top']

        elif direction == 'S':

            self.faces['top'], self.faces['front'], self.faces['bottom'], \

            self.faces['back'] = self.faces['back'], self.faces['top'], \

            self.faces['front'], self.faces['bottom']

        elif direction == 'E':

            self.faces['top'], self.faces['right'], self.faces['bottom'], \

            self.faces['left'] = self.faces['left'], self.faces['top'], \

            self.faces['right'], self.faces['bottom']

        else:

            self.faces['top'], self.faces['right'], self.faces['bottom'], \

            self.faces['left'] = self.faces['right'], self.faces['bottom'], \

            self.faces['left'], self.faces['top']





face_vals = input().split()



dice = Dice(face_vals)



for i in eval(input()):

    dice.roll(i)



print((dice.faces['top']))
class Dice:
    def __init__(self, face_vals):
        self.faces = dict(
            list(zip(["top", "south", "east", "west", "north", "bottom"], face_vals))
        )

    def roll(self, direction):
        if direction == "N":
            (
                self.faces["top"],
                self.faces["south"],
                self.faces["bottom"],
                self.faces["north"],
            ) = (
                self.faces["south"],
                self.faces["bottom"],
                self.faces["north"],
                self.faces["top"],
            )
        elif direction == "S":
            (
                self.faces["top"],
                self.faces["south"],
                self.faces["bottom"],
                self.faces["north"],
            ) = (
                self.faces["north"],
                self.faces["top"],
                self.faces["south"],
                self.faces["bottom"],
            )
        elif direction == "E":
            (
                self.faces["top"],
                self.faces["east"],
                self.faces["bottom"],
                self.faces["west"],
            ) = (
                self.faces["west"],
                self.faces["top"],
                self.faces["east"],
                self.faces["bottom"],
            )
        else:
            (
                self.faces["top"],
                self.faces["east"],
                self.faces["bottom"],
                self.faces["west"],
            ) = (
                self.faces["east"],
                self.faces["bottom"],
                self.faces["west"],
                self.faces["top"],
            )


face_vals = input().split()
dice = Dice(face_vals)
for i in eval(input()):
    dice.roll(i)
print((dice.faces["top"]))

class Dice:
    def __init__(self, face_vals):
        self.faces = dict(
            list(zip(["top", "front", "right", "left", "back", "bottom"], face_vals))
        )

    def roll(self, direction):
        if direction == "N":
            (
                self.faces["top"],
                self.faces["front"],
                self.faces["bottom"],
                self.faces["back"],
            ) = (
                self.faces["front"],
                self.faces["bottom"],
                self.faces["back"],
                self.faces["top"],
            )
        elif direction == "S":
            (
                self.faces["top"],
                self.faces["front"],
                self.faces["bottom"],
                self.faces["back"],
            ) = (
                self.faces["back"],
                self.faces["top"],
                self.faces["front"],
                self.faces["bottom"],
            )
        elif direction == "E":
            (
                self.faces["top"],
                self.faces["right"],
                self.faces["bottom"],
                self.faces["left"],
            ) = (
                self.faces["left"],
                self.faces["top"],
                self.faces["right"],
                self.faces["bottom"],
            )
        else:
            (
                self.faces["top"],
                self.faces["right"],
                self.faces["bottom"],
                self.faces["left"],
            ) = (
                self.faces["right"],
                self.faces["bottom"],
                self.faces["left"],
                self.faces["top"],
            )


face_vals = input().split()
dice = Dice(face_vals)
for i in eval(input()):
    dice.roll(i)
print((dice.faces["top"]))

-            list(zip(["top", "south", "east", "west", "north", "bottom"], face_vals)) +            list(zip(["top", "front", "right", "left", "back", "bottom"], face_vals)) -                self.faces["south"], +                self.faces["front"], -                self.faces["north"], +                self.faces["back"], -                self.faces["south"], +                self.faces["front"], -                self.faces["north"], +                self.faces["back"], -                self.faces["south"], +                self.faces["front"], -                self.faces["north"], +                self.faces["back"], -                self.faces["north"], +                self.faces["back"], -                self.faces["south"], +                self.faces["front"], -                self.faces["east"], +                self.faces["right"], -                self.faces["west"], +                self.faces["left"], -                self.faces["west"], +                self.faces["left"], -                self.faces["east"], +                self.faces["right"], -                self.faces["east"], +                self.faces["right"], -                self.faces["west"], +                self.faces["left"], -                self.faces["east"], +                self.faces["right"], -                self.faces["west"], +                self.faces["left"],