class Dice:

    def __init__(self):

        self.faces=[]



    def rotate(self, direction):

        tmp = self.faces.copy()



        if direction =="N":

            self.faces[5-1] = tmp[1-1]

            self.faces[1-1] = tmp[2-1]

            self.faces[2-1] = tmp[6-1]

            self.faces[6-1] = tmp[5-1]

        if direction =="S":

            self.faces[5-1] = tmp[6-1]

            self.faces[1-1] = tmp[5-1]

            self.faces[2-1] = tmp[1-1]

            self.faces[6-1] = tmp[2-1]

        if direction =="W":

            self.faces[4-1] = tmp[1-1]

            self.faces[1-1] = tmp[3-1]

            self.faces[3-1] = tmp[6-1]

            self.faces[6-1] = tmp[4-1]

        if direction =="E":

            self.faces[3-1] = tmp[1-1]

            self.faces[1-1] = tmp[4-1]

            self.faces[4-1] = tmp[6-1]

            self.faces[6-1] = tmp[3-1]

        return 0







d1 = Dice()

d1.faces=[int(x) for x in input().split(" ")]

directions=list(eval(input()))

for d in directions:

    d1.rotate(d)

print((d1.faces[0]))
def roll(l, command):

    '''

    return rolled list



    l : string list

    command: string

    '''

    res = []

    i = -1

    if command =='N':

        res = [l[i+2], l[i+6], l[i+3], l[i+4], l[i+1], l[i+5]]

    if command =='S':

        res = [l[i+5], l[i+1], l[i+3], l[i+4], l[i+6], l[i+2]]

    if command =='E':

        res = [l[i+4], l[i+2], l[i+1], l[i+6], l[i+5], l[i+3]]

    if command =='W':

        res = [l[i+3], l[i+2], l[i+6], l[i+1], l[i+5], l[i+4]]



    return res



faces = input().split()

commands = list(eval(input()))



for command in commands:

    faces = roll(faces, command)



print((faces[0]))



class Dice:
    def __init__(self):
        self.faces = []

    def rotate(self, direction):
        tmp = self.faces.copy()
        if direction == "N":
            self.faces[5 - 1] = tmp[1 - 1]
            self.faces[1 - 1] = tmp[2 - 1]
            self.faces[2 - 1] = tmp[6 - 1]
            self.faces[6 - 1] = tmp[5 - 1]
        if direction == "S":
            self.faces[5 - 1] = tmp[6 - 1]
            self.faces[1 - 1] = tmp[5 - 1]
            self.faces[2 - 1] = tmp[1 - 1]
            self.faces[6 - 1] = tmp[2 - 1]
        if direction == "W":
            self.faces[4 - 1] = tmp[1 - 1]
            self.faces[1 - 1] = tmp[3 - 1]
            self.faces[3 - 1] = tmp[6 - 1]
            self.faces[6 - 1] = tmp[4 - 1]
        if direction == "E":
            self.faces[3 - 1] = tmp[1 - 1]
            self.faces[1 - 1] = tmp[4 - 1]
            self.faces[4 - 1] = tmp[6 - 1]
            self.faces[6 - 1] = tmp[3 - 1]
        return 0


d1 = Dice()
d1.faces = [int(x) for x in input().split(" ")]
directions = list(eval(input()))
for d in directions:
    d1.rotate(d)
print((d1.faces[0]))

def roll(l, command):
    """
    return rolled list
    l : string list
    command: string
    """
    res = []
    i = -1
    if command == "N":
        res = [l[i + 2], l[i + 6], l[i + 3], l[i + 4], l[i + 1], l[i + 5]]
    if command == "S":
        res = [l[i + 5], l[i + 1], l[i + 3], l[i + 4], l[i + 6], l[i + 2]]
    if command == "E":
        res = [l[i + 4], l[i + 2], l[i + 1], l[i + 6], l[i + 5], l[i + 3]]
    if command == "W":
        res = [l[i + 3], l[i + 2], l[i + 6], l[i + 1], l[i + 5], l[i + 4]]
    return res


faces = input().split()
commands = list(eval(input()))
for command in commands:
    faces = roll(faces, command)
print((faces[0]))

-class Dice: -    def __init__(self): -        self.faces = [] - -    def rotate(self, direction): -        tmp = self.faces.copy() -        if direction == "N": -            self.faces[5 - 1] = tmp[1 - 1] -            self.faces[1 - 1] = tmp[2 - 1] -            self.faces[2 - 1] = tmp[6 - 1] -            self.faces[6 - 1] = tmp[5 - 1] -        if direction == "S": -            self.faces[5 - 1] = tmp[6 - 1] -            self.faces[1 - 1] = tmp[5 - 1] -            self.faces[2 - 1] = tmp[1 - 1] -            self.faces[6 - 1] = tmp[2 - 1] -        if direction == "W": -            self.faces[4 - 1] = tmp[1 - 1] -            self.faces[1 - 1] = tmp[3 - 1] -            self.faces[3 - 1] = tmp[6 - 1] -            self.faces[6 - 1] = tmp[4 - 1] -        if direction == "E": -            self.faces[3 - 1] = tmp[1 - 1] -            self.faces[1 - 1] = tmp[4 - 1] -            self.faces[4 - 1] = tmp[6 - 1] -            self.faces[6 - 1] = tmp[3 - 1] -        return 0 +def roll(l, command): +    """ +    return rolled list +    l : string list +    command: string +    """ +    res = [] +    i = -1 +    if command == "N": +        res = [l[i + 2], l[i + 6], l[i + 3], l[i + 4], l[i + 1], l[i + 5]] +    if command == "S": +        res = [l[i + 5], l[i + 1], l[i + 3], l[i + 4], l[i + 6], l[i + 2]] +    if command == "E": +        res = [l[i + 4], l[i + 2], l[i + 1], l[i + 6], l[i + 5], l[i + 3]] +    if command == "W": +        res = [l[i + 3], l[i + 2], l[i + 6], l[i + 1], l[i + 5], l[i + 4]] +    return res -d1 = Dice() -d1.faces = [int(x) for x in input().split(" ")] -directions = list(eval(input())) -for d in directions: -    d1.rotate(d) -print((d1.faces[0])) +faces = input().split() +commands = list(eval(input())) +for command in commands: +    faces = roll(faces, command) +print((faces[0]))