#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n = input()
            if n == 0:
                break
            f = raw_input().split()
            state = 0
            prev = 0
            ans = 0
            for move in f:
                # print state, prev, ans
                if state == 0:
                    if prev == 3:
                        ans += 1
                        prev = 0
                    if move == 'lu':
                        state = 1
                    elif move == 'ru':
                        state = 2
                elif state == 1:
                    if move == 'ld':
                        state = 0
                    elif move == 'ru':
                        state = 3
                elif state == 2:
                    if move == 'lu':
                        state = 3
                    elif move == 'rd':
                        state = 0
                else:
                    if prev == 0:
                        ans += 1
                        prev = 3
                    if move == 'ld':
                        state = 2
                    elif move == 'rd':
                        state = 1
            if (state == 0 and prev == 3) or (state == 3 and prev == 0):
                ans += 1            
            print ans
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()