while True:
    n = int(raw_input())

    if n == 0:
        break

    f = raw_input().split()

    ans = 0

    for i in range(1, len(f)):
        if f[i] == "lu" and f[i-1] == "ru":
            ans += 1
        elif f[i] == "ru" and f[i-1] == "lu":
            ans += 1
        elif f[i] == "ld" and f[i-1] == "rd":
            ans += 1
        elif f[i] == "rd" and f[i-1] == "ld":
            ans += 1

    print ans
