from sys import stdin

from collections import deque

readline = stdin.readline

h, w = list(map(int, readline().split()))

w += 1

dp = [list(map(int, readline().split())) + [1] for _ in range(h)]

for i in range(h):

    for j in range(w):

        dp[i][j] ^= 1

for i in range(1, h):

    for j in range(w):

        if dp[i][j]:

            dp[i][j] += dp[i - 1][j]

max_s = 0

for i in range(h):

    stack = deque()

    for j in range(w):

        if (stack[-1][0] if stack else 0) < dp[i][j]:

            stack.append((dp[i][j], j))

        elif stack and stack[-1][0] > dp[i][j]:

            while stack and stack[-1][0] > dp[i][j]:

                height, l = stack.pop()

                s = height * (j - l)

                if max_s < s:

                    max_s = s

            if dp[i][j]:

                stack.append((dp[i][j], l))

print(max_s)
from sys import stdin

from collections import deque

def judge(n,hs):

    stack = deque()

    ans = 0

    for i, h in enumerate(hs):

        j = -1

        while stack and stack[-1][1] > h:

            j, h2 = stack.pop()

            ans = max(ans, (i - j) * h2)

        if not stack or stack[-1][1] < h:

            stack.append((i if j == -1 else j, h))

    ans = max(ans, max((n - j) * h2 for j, h2 in stack))

    return ans

H,W = list(map(int,stdin.readline().split()))

hs = [0]*W

result = 0

for i in range(H):

    ht = list(map(int, stdin.readline().split()))

    hs = list(map(lambda x,y:(x+1)*abs(y-1),hs,ht))

    result = max(result,judge(W,hs))

print(result)
from sys import stdin
from collections import deque

readline = stdin.readline
h, w = list(map(int, readline().split()))
w += 1
dp = [list(map(int, readline().split())) + [1] for _ in range(h)]
for i in range(h):
    for j in range(w):
        dp[i][j] ^= 1
for i in range(1, h):
    for j in range(w):
        if dp[i][j]:
            dp[i][j] += dp[i - 1][j]
max_s = 0
for i in range(h):
    stack = deque()
    for j in range(w):
        if (stack[-1][0] if stack else 0) < dp[i][j]:
            stack.append((dp[i][j], j))
        elif stack and stack[-1][0] > dp[i][j]:
            while stack and stack[-1][0] > dp[i][j]:
                height, l = stack.pop()
                s = height * (j - l)
                if max_s < s:
                    max_s = s
            if dp[i][j]:
                stack.append((dp[i][j], l))
print(max_s)

from sys import stdin
from collections import deque


def judge(n, hs):
    stack = deque()
    ans = 0
    for i, h in enumerate(hs):
        j = -1
        while stack and stack[-1][1] > h:
            j, h2 = stack.pop()
            ans = max(ans, (i - j) * h2)
        if not stack or stack[-1][1] < h:
            stack.append((i if j == -1 else j, h))
    ans = max(ans, max((n - j) * h2 for j, h2 in stack))
    return ans


H, W = list(map(int, stdin.readline().split()))
hs = [0] * W
result = 0
for i in range(H):
    ht = list(map(int, stdin.readline().split()))
    hs = list(map(lambda x, y: (x + 1) * abs(y - 1), hs, ht))
    result = max(result, judge(W, hs))
print(result)

-readline = stdin.readline -h, w = list(map(int, readline().split())) -w += 1 -dp = [list(map(int, readline().split())) + [1] for _ in range(h)] -for i in range(h): -    for j in range(w): -        dp[i][j] ^= 1 -for i in range(1, h): -    for j in range(w): -        if dp[i][j]: -            dp[i][j] += dp[i - 1][j] -max_s = 0 -for i in range(h): + +def judge(n, hs): -    for j in range(w): -        if (stack[-1][0] if stack else 0) < dp[i][j]: -            stack.append((dp[i][j], j)) -        elif stack and stack[-1][0] > dp[i][j]: -            while stack and stack[-1][0] > dp[i][j]: -                height, l = stack.pop() -                s = height * (j - l) -                if max_s < s: -                    max_s = s -            if dp[i][j]: -                stack.append((dp[i][j], l)) -print(max_s) +    ans = 0 +    for i, h in enumerate(hs): +        j = -1 +        while stack and stack[-1][1] > h: +            j, h2 = stack.pop() +            ans = max(ans, (i - j) * h2) +        if not stack or stack[-1][1] < h: +            stack.append((i if j == -1 else j, h)) +    ans = max(ans, max((n - j) * h2 for j, h2 in stack)) +    return ans + + +H, W = list(map(int, stdin.readline().split())) +hs = [0] * W +result = 0 +for i in range(H): +    ht = list(map(int, stdin.readline().split())) +    hs = list(map(lambda x, y: (x + 1) * abs(y - 1), hs, ht)) +    result = max(result, judge(W, hs)) +print(result)