m, n = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)
count = 0
if m == 2
    temp = [0, 0]
    arr.each_with_index{|x, i|
        if i.even?
            temp[0] += 1 if x == 1
        else
            temp[0] += 1 if x == 2
        end
    }
    arr.each_with_index{|x, i|
        if i.even?
            temp[1] += 1 if x == 2
        else
            temp[1] += 1 if x == 1
        end
    }
    count = temp.min
else
    1.upto(n - 1){|i|
        if arr[i - 1] == arr[i]
            count += 1
            arr[i] = 0
        end
    }
end
puts count
