object Main {
    def step(s: (Int, Int, Int), i: Char) = i match {
        case 'N' => (s._2, 5-s._1, s._3)
        case 'E'  => (5-s._3, s._2, s._1)
        case 'W'  => (s._3, s._2, 5-s._1)
        case 'S' => (5-s._2, s._1, s._3)
    }
 
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines
        val nums = in.next.split(" ").map(_.toInt)
        println(nums(in.next.foldLeft((0, 1, 2))(step)._1))
    }
}