"use strict"

const fs = require("fs");

Array.prototype.group =
    function* (key = (a) => { return a; }) {
        if ( this.length === 0 )
            return;
        
        let val = key(this[0]);
        let from_idx = 0;
        let curr_idx = 1;
        while( curr_idx < this.length ){
            let val2 = key(this[curr_idx]);
            if (val !== val2) {
                yield this.slice(from_idx, curr_idx);
                val = val2;
                from_idx = curr_idx;
                curr_idx++;
            } else
                curr_idx++;
        }

        yield this.slice(from_idx);
    }

let inputs = fs.readFileSync("/dev/stdin").toString().split("\n");
let N = Number(inputs[0]);
let as = inputs[1].split(" ").map(Number);

console.log(
    Array.from(as.group())
        .map((a) => { return Math.floor(a.length/2); })
        .reduce((a, b) => { return a+b; }, 0));

