def solve(f):
    cnt = 0
    for i in range(len(f)-1):
        if f[i][1] == f[i+1][1]:
            cnt += 1
    return cnt

while True:
    n = int(raw_input())
    if n == 0:
        break
    f = raw_input().split(" ")
    print solve(f)
