1. 

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10074 - Take the Land
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=12&problem=1015&mosmsg=Submission+received+with+ID+8027444
*
* @author Evgeni Pavlidis
* @version 1.0, 06/08/2010
*
* Method : Kadane - Max substring
* Status : Accepted
* Runtime: 0.232
*/

import java.io.*;
import java.util.*;

class Main {

private static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

private static int nextInt() throws Exception
{
st.nextToken();
return (int)st.nval;
}

public static void main(String...args) throws Exception
{
int[][] rowSum = new int[102][102];
int rows, columns, sum = 0, max, t;

while(true)
{
rows = nextInt();
columns = nextInt();

if(rows == 0 && columns == 0)
break;


// accumulate row sums
for(int r = 0; r < rows; r++, sum = 0)
for(int c = 0; c < columns; c++)
rowSum[r][c+1] = sum = sum + ((t = nextInt()) == 1? -(100*100): 1);


// find max substring (submatrix)
max = 0;
for(int c1 = 1; c1 <= columns; c1++)
for(int c2 = c1; c2 <= columns; c2++, sum = 0)
for(int r = 0; r < rows; r++)
{
sum += rowSum[r][c2] - rowSum[r][c1-1];

if(sum < 0)
sum = 0;

if(sum > max)
max = sum;
}

System.out.println(max);
}
}
}