class Dice
    @faces = nil
 
    def initialize arr
        @faces = arr
    end
 
    def top
        @faces[0]
    end
 
    def rotate news
        f = @faces.dup
        case news
        when "North"
            @faces = [f[1], f[5], f[2], f[3], f[0], f[4]]
        when "East"
            @faces = [f[3], f[1], f[0], f[5], f[4], f[2]]
        when "West"
            @faces = [f[2], f[1], f[5], f[0], f[4], f[3]]
        when "South"
            @faces = [f[4], f[0], f[2], f[3], f[5], f[1]]
        when "Right"
            @faces = [f[0], f[2], f[4], f[1], f[3], f[5]]
        when "Left"
            @faces = [f[0], f[3], f[1], f[4], f[2], f[5]]
        end
    end
end

while true
    n = gets.to_i
    break if n == 0
    sum = 1
    dice = Dice.new [1,2,3,4,5,6]
    n.times{
        dice.rotate gets.chomp
        sum += dice.top
    }
    puts sum
end

