h, n = gets.split.map(&:to_i)

obs = {}
n.times do
    x, y = gets.split.map(&:to_i)
    (obs[y] ||= []) << x
end

b = 0
(obs[0] || []).each do |i|
    b |= (1 << i)
end

c = 0

(1..h-1).each do |i|
    b = (b & 0b1111) << 4
    (obs[i] || []).each do |j|
        b |= (1 << j)
    end
    [0b11111111, 0b11001100, 0b01100110, 0b00110011].each do |pattern|
        if b & pattern == 0
            b |= pattern
            c += (pattern == 0b11111111 ? 2 : 1)
            break
        end
    end
end
p c

