h, n = gets.split.map(&:to_i)
 
obs = Hash.new(0b00000000)
n.times do
    x, y = gets.split.map(&:to_i)
    obs[y] |= (1 << x)
end
 
patterns = {
    0b11111111 => 2,
    0b11001100 => 1,
    0b01100110 => 1,
    0b00110011 => 1,
    0b00000000 => 0,
}
 
tab = {obs[0] => 0}
(1..h-1).each do |i|
    new_tab = Hash.new(-Float::INFINITY)
    tab.keys.each do |b|
        x = ((b & 0b1111) << 4) | obs[i]
        patterns.each do |pattern, k|
            if x & pattern == 0
                y = (x | pattern)
                c = tab[b] + k
                new_tab[y] = c if c > new_tab[y]
            end
            pattern <<= 1
        end
    end
    tab = new_tab
end

p tab.values.max

