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;
        foreach(e; seq){
            bool bUpdate;

            if(state == 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)
                ++cnt;
        }

        writeln(cnt);
    }
}