while true
    n = gets.to_i
    break if n == 0

    arr = gets.chomp.split
    status = [[false, false], [true, true]]
    count = 0
    arr.each{|step|
        case step
        when "lu" then status[0][0] = true
        when "ru" then status[0][1] = true
        when "ld" then status[0][0] = false
        when "rd" then status[0][1] = false
        end
        if status[0] == status[1]
            count += 1
            status[1] = [!status[1][0], !status[1][1]]
        end
    }
    puts count
end
