import java.util.*

data class Dice(val value: List<Int>) {
    var top = 1
    var south = 2
    var east = 3
    var west = 4
    var north = 5
    var bottom = 6

    fun rolls(ds: String) {
        for (d in ds) {
            roll(d)
        }
    }

    fun roll(d: Char) {
        if (d == 'S') {
            val w = top
            top = north
            north = bottom
            bottom = south
            south = w
        } else if (d == 'N') {
            val w = top
            top = south
            south = bottom
            bottom = north
            north = w
        } else if (d == 'E') {
            val w = top
            top = west
            west = bottom
            bottom = east
            east = w
        } else if (d == 'W') {
            val w = top
            top = east
            east = bottom
            bottom = west
            west = w
        }
    }
    fun top() = this.value.get(top - 1)
}

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val dice = Dice(listOf(
        scanner.nextInt(),
        scanner.nextInt(),
        scanner.nextInt(),
        scanner.nextInt(),
        scanner.nextInt(),
        scanner.nextInt()))
    dice.rolls(scanner.next())

    println(dice.top())
}

