object Main {
    def step(s: (Int, Int, Int), i: String) = i match {
        case "North" => (s._2, 7-s._1, s._3)
        case "East"  => (7-s._3, s._2, s._1)
        case "West"  => (s._3, s._2, 7-s._1)
        case "South" => (7-s._2, s._1, s._3)
        case "Right" => (s._1, s._3, 7-s._2)
        case "Left"  => (s._1, 7-s._3, s._2)
    }

    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines
        for (n <- in if n != "0") println(in.take(n.toInt).scanLeft((1, 2, 3))(step).map(_._1).sum)
    }
}