loop do
    n = gets.to_i
    break if n == 0
    steps = gets.split
    c = [0,0,0]
    count = 0
    steps.each do |s|
        case s
        when "lu"
            c[1] = 1
            if c[0] == 0 && c[2] == 1
                count += 1
                c[0] = 1
            end
        when "ru"
            c[2] = 1
            if c[0] == 0 && c[1] == 1
                count += 1
                c[0] = 1
            end
        when "ld"
            c[1] = 0
            if c[0] == 1 && c[2] == 0
                count += 1
                c[0] = 0
            end
        when "rd"
            c[2] = 0
            if c[0] == 1 && c[2] == 0
                count += 1
                c[0] = 0
            end
        end
    end
    puts count
end