Consider a matrix of m by n sized grid where some cells are blocked. How many possible paths from start to finish are there?
Assume the start is the top-left cell and the finish is the bottom-right cell. A valid path moves only right or down and cannot enter a blocked cell. Implement count_paths(grid), where grid is a rectangular matrix containing 0 for open cells and 1 for blocked cells; return the number of valid paths as an integer.
def count_paths(grid):