object Main {
    def step(s: Array[Int], i: String): Array[Int] = i match {
        case "North" => s.updated(3, s(0)).updated(0, s(1)).updated(1, 7 - s(0))
        case "East"  => s.updated(2, s(0)).updated(0, s(4)).updated(4, 7 - s(0))
        case "West"  => s.updated(4, s(0)).updated(0, s(2)).updated(2, 7 - s(0))
        case "South" => s.updated(1, s(0)).updated(0, s(3)).updated(3, 7 - s(0))
        case "Right" => s.updated(1, s(2)).updated(2, s(3)).updated(3, s(4)).updated(4, s(1))
        case "Left"  => s.updated(1, s(4)).updated(2, s(1)).updated(3, s(2)).updated(4, s(3))
    }

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