class Dice(object):

    def __init__(self, top, south, east, west, north, bottom):

        self.top = top

        self.south = south

        self.east = east

        self.west = west

        self.north = north

        self.bottom = bottom



    def get_top(self):

        return self.top



    def rotate(self, directions):

        for direction in directions:

            if direction == 'S':

                self.prev_top = self.top

                self.top = self.north

                self.north = self.bottom

                self.bottom = self.south

                self.south = self.prev_top

            elif direction == 'E':

                self.prev_top = self.top

                self.top = self.west

                self.west = self.bottom

                self.bottom = self.east

                self.east = self.prev_top

            elif direction == 'W':

                self.prev_top = self.top

                self.top = self.east

                self.east = self.bottom

                self.bottom = self.west

                self.west = self.prev_top

            elif direction == 'N':

                self.prev_top = self.top

                self.top = self.south

                self.south = self.bottom

                self.bottom = self.north

                self.north = self.prev_top



dice = Dice(*list(map(int, input().split())))

dice.rotate(eval(input()))

print((dice.get_top()))
class Dice:

    def __init__(self, top, front, right, left, back, bottom):

        self.top = top

        self.front = front

        self.right = right

        self.left = left

        self.back = back

        self.bottom = bottom



    def print_top(self):

        print((self.top))



    def roll(self, direction):

        if direction == 'S':

            self.south()

        elif direction == 'N':

            self.north()

        elif direction == 'E':

            self.east()

        elif direction == 'W':

            self.west()



    def north(self):

        [self.top, self.back, self.bottom, self.front] = [self.front, self.top, self.back, self.bottom]



    def south(self):

        [self.top, self.back, self.bottom, self.front] = [self.back, self.bottom, self.front, self.top]



    def east(self):

        [self.top, self.right, self.bottom, self.left] = [self.left, self.top, self.right, self.bottom]



    def west(self):

        [self.top, self.right, self.bottom, self.left] = [self.right, self.bottom, self.left, self.top]





labels = input().split()

directions = eval(input())



dice = Dice(*labels)

for direction in directions:

    dice.roll(direction)

dice.print_top()



class Dice(object):
    def __init__(self, top, south, east, west, north, bottom):
        self.top = top
        self.south = south
        self.east = east
        self.west = west
        self.north = north
        self.bottom = bottom

    def get_top(self):
        return self.top

    def rotate(self, directions):
        for direction in directions:
            if direction == "S":
                self.prev_top = self.top
                self.top = self.north
                self.north = self.bottom
                self.bottom = self.south
                self.south = self.prev_top
            elif direction == "E":
                self.prev_top = self.top
                self.top = self.west
                self.west = self.bottom
                self.bottom = self.east
                self.east = self.prev_top
            elif direction == "W":
                self.prev_top = self.top
                self.top = self.east
                self.east = self.bottom
                self.bottom = self.west
                self.west = self.prev_top
            elif direction == "N":
                self.prev_top = self.top
                self.top = self.south
                self.south = self.bottom
                self.bottom = self.north
                self.north = self.prev_top


dice = Dice(*list(map(int, input().split())))
dice.rotate(eval(input()))
print((dice.get_top()))

class Dice:
    def __init__(self, top, front, right, left, back, bottom):
        self.top = top
        self.front = front
        self.right = right
        self.left = left
        self.back = back
        self.bottom = bottom

    def print_top(self):
        print((self.top))

    def roll(self, direction):
        if direction == "S":
            self.south()
        elif direction == "N":
            self.north()
        elif direction == "E":
            self.east()
        elif direction == "W":
            self.west()

    def north(self):
        [self.top, self.back, self.bottom, self.front] = [
            self.front,
            self.top,
            self.back,
            self.bottom,
        ]

    def south(self):
        [self.top, self.back, self.bottom, self.front] = [
            self.back,
            self.bottom,
            self.front,
            self.top,
        ]

    def east(self):
        [self.top, self.right, self.bottom, self.left] = [
            self.left,
            self.top,
            self.right,
            self.bottom,
        ]

    def west(self):
        [self.top, self.right, self.bottom, self.left] = [
            self.right,
            self.bottom,
            self.left,
            self.top,
        ]


labels = input().split()
directions = eval(input())
dice = Dice(*labels)
for direction in directions:
    dice.roll(direction)
dice.print_top()

-class Dice(object): -    def __init__(self, top, south, east, west, north, bottom): +class Dice: +    def __init__(self, top, front, right, left, back, bottom): -        self.south = south -        self.east = east -        self.west = west -        self.north = north +        self.front = front +        self.right = right +        self.left = left +        self.back = back -    def get_top(self): -        return self.top +    def print_top(self): +        print((self.top)) -    def rotate(self, directions): -        for direction in directions: -            if direction == "S": -                self.prev_top = self.top -                self.top = self.north -                self.north = self.bottom -                self.bottom = self.south -                self.south = self.prev_top -            elif direction == "E": -                self.prev_top = self.top -                self.top = self.west -                self.west = self.bottom -                self.bottom = self.east -                self.east = self.prev_top -            elif direction == "W": -                self.prev_top = self.top -                self.top = self.east -                self.east = self.bottom -                self.bottom = self.west -                self.west = self.prev_top -            elif direction == "N": -                self.prev_top = self.top -                self.top = self.south -                self.south = self.bottom -                self.bottom = self.north -                self.north = self.prev_top +    def roll(self, direction): +        if direction == "S": +            self.south() +        elif direction == "N": +            self.north() +        elif direction == "E": +            self.east() +        elif direction == "W": +            self.west() + +    def north(self): +        [self.top, self.back, self.bottom, self.front] = [ +            self.front, +            self.top, +            self.back, +            self.bottom, +        ] + +    def south(self): +        [self.top, self.back, self.bottom, self.front] = [ +            self.back, +            self.bottom, +            self.front, +            self.top, +        ] + +    def east(self): +        [self.top, self.right, self.bottom, self.left] = [ +            self.left, +            self.top, +            self.right, +            self.bottom, +        ] + +    def west(self): +        [self.top, self.right, self.bottom, self.left] = [ +            self.right, +            self.bottom, +            self.left, +            self.top, +        ] -dice = Dice(*list(map(int, input().split()))) -dice.rotate(eval(input())) -print((dice.get_top())) +labels = input().split() +directions = eval(input()) +dice = Dice(*labels) +for direction in directions: +    dice.roll(direction) +dice.print_top()