loop {
	n = gets.to_i
	break if n == 0
	l = r = 0
	prev = 0
	count = 0
	gets.chomp.split.each{|s|
		case s
			when 'lu'; l = 1
			when 'ld'; l = 0
			when 'ru'; r = 1
			when 'rd'; r = 0
		end
		if l == r && l != prev
			count += 1
			prev = l
		end
	}
	p count
}