while 1:
    n = int(input())
    if n == 0:
        break
    a = b = c = sum = 0
    lst = []
    f = [str(x) for x in raw_input().split()]
    for i in range(n):
        if f[c] == 'lu':
            a += 1
        if f[c] == 'ld':
            a -= 1
        if f[c] == 'ru':
            a += 1
        if f[c] == 'rd':
            a -= 1
        if b == 0:
            if a == 2:
                sum += 1
                b = 1
        if b == 1:
            if a == 0:
                sum += 1
                b = 0
        c += 1
    print sum