Finds number of paths in a Matrix