easy python
```\nclass Solution:\n    def countSquares(self, matrix: List[List[int]]) -> int:\n        ans = 0\n        m,n = len(matrix), len(matrix[0])\n        for i in 
```\nclass Solution:\n    def countSquares(self, matrix: List[List[int]]) -> int:\n        ans = 0\n        m,n = len(matrix), len(matrix[0])\n        for i in range(m):\n            for j in range(n):\n                if i != 0 and j != 0:\n                    if matrix[i][j]:\n                        matrix[i][j] += min(\n                            matrix[i-1][j-1],\n                            matrix[i-1][j],\n                            matrix[i][j-1]\n                        )\n                ans += matrix[i][j]\n        return ans
[]