loop do
  n = gets.chomp.to_i;
  
  if n == 0
    break
  end

  f = gets.chomp.split(" ").map(&:to_s)
  
  ans = 0
  # 0:down, 1:up
  pos = 0
  left = 0
  right = 0

  n.times do |i|
    if f[i] == 'lu' || f[i] == 'ld'
      left = 1 - left
    else
      right = 1 - right
    end
    
    if pos == 0 && left == 1 && right == 1
      pos = 1
      ans += 1
    elsif pos == 1 && left == 0 && right == 0
      pos = 0
      ans += 1
    end
  end
  
  puts ans
end