fun main(args: Array<String>) {
    val num = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val dice = Dice(num[0],num[1],num[2],num[3],num[4],num[5])
    val order = readLine() ?: return
    order.forEach {
        when(it){
            'N'  -> dice.toN()
            'E'  -> dice.toE()
            'S'  -> dice.toS()
            else -> dice.toW()
        }

    }
    println(dice.getTop())
}

class Dice (var one:Int,
            var two:Int,
            var three:Int,
            var four:Int,
            var five:Int,
            var six:Int){

    fun toN(){
        val temp = one
        one  = two
        two  = six
        six  = five
        five = temp
    }

    fun toS(){
        val temp = one
        one  = five
        five = six
        six  = two
        two  = temp
    }

    fun toE(){
        val temp = one
        one   = four
        four  = six
        six   = three
        three = temp
    }

    fun toW(){
        val temp = one
        one   = three
        three = six
        six   = four
        four  = temp
    }

    fun getTop() : Int {
        return one
    }
}
