import std.stdio;
import std.string;
import std.algorithm;
import std.range;
import std.array;
import std.conv;


void main()
{
    while(1){
        auto N = readln().chomp().to!uint;

        if(N == 0)
            break;

        auto seq = readln().chomp().split();
        uint state;
        uint cnt;
        uint lastState = 0;
        foreach(e; seq){
            bool bUpdate;

            if(((state & 1) == 0 || (state & 2) == 0) && (e == "lu" || e == "ru")){
                bUpdate = true;
                state += e == "lu" ? 1 : 2;
            }
            else if((state & 1) == 1 && e == "ld"){
                bUpdate = true;
                state -= 1;
            }else if((state & 2) == 2 && e == "rd"){
                bUpdate = true;
                state -= 2;
            }

            if(bUpdate && (state == 3 || state == 0) && lastState != state){
                lastState = state;
                ++cnt;
            }
        }

        writeln(cnt);
    }
}