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

public class garnett_dk {
	BufferedReader br;
	PrintWriter out;
	StringTokenizer stok;

	String nextToken() throws IOException {
		while (stok == null || !stok.hasMoreTokens()) {
			String s = br.readLine();
			if (s == null) {
				return null;
			}
			stok = new StringTokenizer(s);
		}
		return stok.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	char nextChar() throws IOException {
		return (char) (br.read());
	}

	String nextLine() throws IOException {
		return br.readLine();
	}
	int max(int a, int b) {
	  return (a < b ? b : a); 
	}


	int q;
	void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int i1 = -1, j1 = -1, i2 = -1, j2 = -1;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				q = nextInt();
				if (q == 1) {
					if (i1 == -1) {
						i1 = i;
						j1 = j;
					} else {
						i2 = i;
						j2 = j;
					}
				}
			}
		}
		int ans = 0;
		if (i1 == i2) {
			if (j2 > j1) {
				ans = max(ans, n * (m - j1 - 1));
				ans = max(ans, n * j2);
			} else 
			 {
				ans = max(ans, n * (m - j2 - 1));
				ans = max(ans, n * j1);
			}

		} else if (j1 == j2) {
			if (i2 > i1) {
				ans = max(ans, m * (n - i1 - 1));
				ans = max(ans, m * i2);
			} else 
			 {
				ans = max(ans, m * (n - i2 - 1));
				ans = max(ans, m * i1);
			}
		} else {

			if (j2 > j1) {
				ans = max(ans, n * (m - j1 - 1));
				ans = max(ans, n * j2);
			}
			if (j1 > j2) {
				ans = max(ans, n * (m - j2 - 1));
				ans = max(ans, n * j1);
			}
			if (i2 > i1) {
				ans = max(ans, m * (n - i1 - 1));
				ans = max(ans, m * i2);
			}
			if (i1 > i2) {
				ans = max(ans, m * (n - i2 - 1));
				ans = max(ans, m * i1);
			}
		}
		out.println(ans);
	}

	void run() throws IOException {
		br = new BufferedReader(new FileReader("garnett.in"));
		out = new PrintWriter("garnett.out");
		solve();
		br.close();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new garnett_dk().run();
	}
}
