fun main(args: Array<String>){
    d1()
}

class Dice(val face_origin: List<Int>,val roll: String){

    val face = face_origin.toMutableList()

    fun print_dice(){
        println(face)
        println(roll)
    }

    fun dice_rotation():MutableList<Int>{
        for(i in 0..roll.length-1){
            val direction = roll.substring(i,i+1)
            var tmp:Int
            when{
                direction == "N" ->{
                    tmp=face[0];face[0]=face[1];face[1]=face[5];face[5]=face[4];face[4]=tmp
                }
                direction == "E" ->{
                    tmp=face[0];face[0]=face[3];face[3]=face[5];face[5]=face[2];face[2]=tmp
                }
                direction == "W" ->{
                    tmp=face[0];face[0]=face[2];face[2]=face[5];face[5]=face[3];face[3]=tmp
                }
                direction == "S" ->{
                    tmp=face[0];face[0]=face[4];face[4]=face[5];face[5]=face[1];face[1]=tmp
                }
            }
        }
        return face
    }
}

fun d1(){
    val a = readLine()!!.split(" ").map(String::toInt)
    val b = readLine()!!
    val dice1 = Dice(a,b)
    val c = dice1.dice_rotation()
    println(c[0])
}
