while True:
  n = int(raw_input())
  if n == 0: break
  s = raw_input().split()
  state = [False, False]
  counter = 0
  stand = False
  for step in s:
    if step == "lu":
      state[0] = True
    elif step == "ru":
      state[1] = True
    elif step == "ld":
      state[0] = False
    elif step == "rd":
      state[1] = False

    if state[0] == state[1] and stand != state[0]:
      counter += 1
      stand = state[0]
  print counter