import std.stdio, std.conv, std.string;

void main()
{
  while ( true ) {
	immutable int n = to!int( readln().strip() );
	if ( n == 0 ) break;

	int count = 0;
	bool right = false;
	bool left = false;
	bool isUp = false;
	foreach ( s; split( readln() ) ) {
	  switch ( s ) {
	  case "lu":
		left = true;
		break;
	  case "ld":
		left = false;
		break;
	  case "ru":
		right = true;
		break;
	  case "rd":
		right = false;
		break;
	  default :
	  }
	  if ( isUp && !right && !left ) {
		isUp = false;
		count++;
	  } else if ( !isUp && right && left ) {
		isUp = true;
		count++;
	  }
	}
	writeln( count );
  }
}