while True:
    n = int(raw_input())
    if n == 0: break
    move = raw_input().split()
    l,r,go,count = 0,0,1,0
    for c in move:
        if c == 'lu':
            l = 1
        if c == 'ru':
            r = 1
        if c == 'ld':
            l = 0
        if c == 'rd':
            r = 0
        if l == r and l == go:
            count += 1
            go = -l + 1
    print count