import copy





class Dice:

    def __init__(self, eyes):

        self._top = eyes[0]

        self._front = eyes[1]

        self._right = eyes[2]

        self._left = eyes[3]

        self._back = eyes[4]

        self._bottom = eyes[5]



    @property

    def eye(self):

        return self._top



    def roll(self, direction):

        old = copy.copy(self)

        if direction == 'N':

            self._top = old._front

            self._front = old._bottom

            self._back = old._top

            self._bottom = old._back

        elif direction == 'S':

            self._top = old._back

            self._front = old._top

            self._back = old._bottom

            self._bottom = old._front

        elif direction == 'W':

            self._top = old._right

            self._right = old._bottom

            self._left = old._top

            self._bottom = old._left

        elif direction == 'E':

            self._top = old._left

            self._right = old._top

            self._left = old._bottom

            self._bottom = old._right

        else:

            raise ValueError('NEWS箱推し')





eyes = input().split()

dice = Dice(eyes)



direction_text = eval(input())

for d in direction_text:

    dice.roll(d)



print((dice.eye))



class Dice:

    def __init__(self, eyes):

        self._eyes = ['dummy'] + eyes



    @property

    def eye(self):

        return self._eyes[1]



    def roll(self, direction):

        old = self._eyes

        new = ['dummy'] * 7

        if direction == 'N':

            new[1] = old[2]

            new[2] = old[6]

            new[3] = old[3]

            new[4] = old[4]

            new[5] = old[1]

            new[6] = old[5]

        elif direction == 'S':

            new[1] = old[5]

            new[2] = old[1]

            new[3] = old[3]

            new[4] = old[4]

            new[5] = old[6]

            new[6] = old[2]

        elif direction == 'W':

            new[1] = old[3]

            new[2] = old[2]

            new[3] = old[6]

            new[4] = old[1]

            new[5] = old[5]

            new[6] = old[4]

        elif direction == 'E':

            new[1] = old[4]

            new[2] = old[2]

            new[3] = old[1]

            new[4] = old[6]

            new[5] = old[5]

            new[6] = old[3]

        else:

            raise ValueError('NEWS箱推し')

        self._eyes = new





eyes = input().split()

dice = Dice(eyes)



direction_text = eval(input())

for d in direction_text:

    dice.roll(d)



print((dice.eye))



import copy


class Dice:
    def __init__(self, eyes):
        self._top = eyes[0]
        self._front = eyes[1]
        self._right = eyes[2]
        self._left = eyes[3]
        self._back = eyes[4]
        self._bottom = eyes[5]

    @property
    def eye(self):
        return self._top

    def roll(self, direction):
        old = copy.copy(self)
        if direction == "N":
            self._top = old._front
            self._front = old._bottom
            self._back = old._top
            self._bottom = old._back
        elif direction == "S":
            self._top = old._back
            self._front = old._top
            self._back = old._bottom
            self._bottom = old._front
        elif direction == "W":
            self._top = old._right
            self._right = old._bottom
            self._left = old._top
            self._bottom = old._left
        elif direction == "E":
            self._top = old._left
            self._right = old._top
            self._left = old._bottom
            self._bottom = old._right
        else:
            raise ValueError("NEWS箱推し")


eyes = input().split()
dice = Dice(eyes)
direction_text = eval(input())
for d in direction_text:
    dice.roll(d)
print((dice.eye))

class Dice:
    def __init__(self, eyes):
        self._eyes = ["dummy"] + eyes

    @property
    def eye(self):
        return self._eyes[1]

    def roll(self, direction):
        old = self._eyes
        new = ["dummy"] * 7
        if direction == "N":
            new[1] = old[2]
            new[2] = old[6]
            new[3] = old[3]
            new[4] = old[4]
            new[5] = old[1]
            new[6] = old[5]
        elif direction == "S":
            new[1] = old[5]
            new[2] = old[1]
            new[3] = old[3]
            new[4] = old[4]
            new[5] = old[6]
            new[6] = old[2]
        elif direction == "W":
            new[1] = old[3]
            new[2] = old[2]
            new[3] = old[6]
            new[4] = old[1]
            new[5] = old[5]
            new[6] = old[4]
        elif direction == "E":
            new[1] = old[4]
            new[2] = old[2]
            new[3] = old[1]
            new[4] = old[6]
            new[5] = old[5]
            new[6] = old[3]
        else:
            raise ValueError("NEWS箱推し")
        self._eyes = new


eyes = input().split()
dice = Dice(eyes)
direction_text = eval(input())
for d in direction_text:
    dice.roll(d)
print((dice.eye))

-import copy - - -        self._top = eyes[0] -        self._front = eyes[1] -        self._right = eyes[2] -        self._left = eyes[3] -        self._back = eyes[4] -        self._bottom = eyes[5] +        self._eyes = ["dummy"] + eyes -        return self._top +        return self._eyes[1] -        old = copy.copy(self) +        old = self._eyes +        new = ["dummy"] * 7 -            self._top = old._front -            self._front = old._bottom -            self._back = old._top -            self._bottom = old._back +            new[1] = old[2] +            new[2] = old[6] +            new[3] = old[3] +            new[4] = old[4] +            new[5] = old[1] +            new[6] = old[5] -            self._top = old._back -            self._front = old._top -            self._back = old._bottom -            self._bottom = old._front +            new[1] = old[5] +            new[2] = old[1] +            new[3] = old[3] +            new[4] = old[4] +            new[5] = old[6] +            new[6] = old[2] -            self._top = old._right -            self._right = old._bottom -            self._left = old._top -            self._bottom = old._left +            new[1] = old[3] +            new[2] = old[2] +            new[3] = old[6] +            new[4] = old[1] +            new[5] = old[5] +            new[6] = old[4] -            self._top = old._left -            self._right = old._top -            self._left = old._bottom -            self._bottom = old._right +            new[1] = old[4] +            new[2] = old[2] +            new[3] = old[1] +            new[4] = old[6] +            new[5] = old[5] +            new[6] = old[3] +        self._eyes = new