R = sum(sum(row) % 2 for row in A) C = sum(sum(col) % 2 for col in zip(*A)) ans = max(R, C)