function Main(input){
    input = input.split("\n");
    var k = 0;
    while(1){
        var n = parseInt(input[k++],10);

        if(n == 0)
            break;
        input[k] = input[k].split(" ");

        var ans = 0;
        for(var i = 0;i < Math.floor(n / 2);i++){
            if(input[k][i * 2][1] == input[k][i * 2 + 1][1])
                ans++;
        }
        console.log(ans);
        k++;
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));