$dx = [0,1,0,-1,1,-1]
$dy = [1,0,-1,0,1,-1]
def bfs(sy, sx, t, blocks)
    q = [[sy,sx]]
    visited = [[sy,sx]]
    steps = Array.new(200).map{Array.new(200,0)}
    count = 1
    steps[sy][sx] = 1
    while q.size > 0
        sy, sx = q.shift
        next if steps[sy][sx] > t
        for i in 0..5
            cy = sy + $dy[i]
            cx = sx + $dx[i]
            if !blocks.include?([cy,cx]) && steps[cy][cx] == 0 && !visited.include?([cy,cx])
                q.push([cy,cx])
                visited.push([cy,cx])
                steps[cy][cx] = steps[sy][sx] + 1
                count += 1
            end
        end
    end
    return count
end
loop do
    t, n = gets.split.map(&:to_i)
    break if t == 0 && n == 0
    blocks = n.times.map{gets.split.map{|c| c.to_i + 100}}
    sy, sx = gets.split.map(&:to_i)
    puts bfs(sy + 100, sx + 100, t, blocks)
end