# the program extends the solution of the problem of finding
# the correct squares. The structure of both problem is analogous,
# or even identical.
# Therefore, the structure of the code and the data representation
# remain the same. The only changes to the code are marked by
# ### CHANGE! ###  comments.


M = 0
N = 0
matrix = []   # has artificial (buffer) border of width 1 filed with 0

'''
...............
..~~~~~~~~.....
..~1AAAAA~.....
..~A....A~.....
..~A....A~.....
..~A....A~.....
..~A....A~.....
..~AAAAAA~.....
..~~~~~~~~ .....
...............

1. Check if all symbols at positions marked by A are 1s.
2. Check if all symbols at positions marked by ~ are 0s.
1. and 2.are accomplished by a single function isRectBorder
as the shapes of the both squares are identical,
only the size and the value 0/1 are different.
'''


# the width of the border is exactly one cell
def isRectBorder(yul, xul, ybr, xbr, value):
    #check both horizontal borders
    for col in range(xul+1, xbr):
        if matrix[yul][col] != value or matrix[ybr][col]!= value:
            return False
    # check both vertical borders
    for row in range(yul+1, ybr+1):
        if matrix[row][xul] != value or matrix[row][xbr] != value:
            return False
    return True


def isOkRectInterior(yul, xul, ybr, xbr):

    # Checking the the condition:
    # In a correct rectangle, the number of 0s in
    # each row and in each column is at most 1

    CountZerosInRow = [0] * M                                ### CHANGE! ###
    CountZerosInCol = [0] * N                                ### CHANGE! ###

    for row in range (yul+1, ybr):
        for col in range( xul+1, xbr):
            if matrix[row][col] == 0:
               CountZerosInRow[row] += 1                     ### CHANGE! ###
               if CountZerosInRow[row] > 1:                  ### CHANGE! ###
                   return False                              ### CHANGE! ###
               CountZerosInCol[col] += 1                     ### CHANGE! ###
               if CountZerosInCol[col] > 1:                  ### CHANGE! ###
                   return False                              ### CHANGE! ###
    return True

def isCorrectRect(yul, xul, ybr, xbr):
    return \
           isRectBorder     (yul-1, xul-1, ybr+1, xbr+1, 0)  \
       and isRectBorder     (yul,   xul,   ybr,   xbr,   1)  \
       and isOkRectInterior (yul,   xul,   ybr,   xbr)


# Removing the check for possible upper left corner   # check! #
# slows down considerably the whole solution.
# Try to explain why.

def solution():
    count = 0
    area = 0
    for yul in range(1, M+1):
        for xul in range(1, N+1):
            if matrix[yul][xul] == 1:
                # can this be a possible upper left corner?
                if matrix[yul-1][xul  ] != 0: continue       # check! #
                if matrix[yul  ][xul-1] != 0: continue       # check! #
                if matrix[yul-1][xul-1] != 0: continue       # check! #

                # search for possible upper *right* corner
                x = xul+1
                while matrix[yul][x] == 1:
                    x += 1

                # search for possible bottom *left* corner
                y = yul+1                                       ### CHANGE! ###
                while matrix[y][xul] == 1:                      ### CHANGE! ###
                    y += 1

                # possible upper right and bottom left corners found,
                # they define the possible bottom right corner as well
                xbr = x - 1                                     ### CHANGE! ###
                ybr = y - 1                                     ### CHANGE! ###
                if ybr > M or xbr > N:                          ### CHANGE! ###
                    continue                                    ### CHANGE! ###
                if isCorrectRect(yul, xul, ybr, xbr):           ### CHANGE! ###
                    count += 1                                  ### CHANGE! ###
                    area += (ybr-yul+1)*(xbr-xul+1)             ### CHANGE! ###
    return count, area


def loadMatrix(M, N):
    mx = []
    border = [0] * (N+2)
    mx.append( border )
    for i in range(M):
        row = list( map( int, input().split() ) )
        mxrow = [0]+row +[0]
        mx.append(mxrow)
    mx.append( border )
    return mx


# -----------------------------------------------------------------------
#   M A I N
# -----------------------------------------------------------------------


M, N = map(int, input().split())
matrix = loadMatrix(M, N)
count, area = solution()
print(count, area)

'''
Example 1


10 11
1 1 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 1 1 1 0 1
0 1 1 0 1 1 1 1 1 0 0
0 1 1 0 1 1 1 1 1 0 1
0 0 0 0 1 1 1 0 1 0 0
0 0 1 0 1 1 1 1 1 0 1
0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 0 1 1 1 0 1 0
1 1 1 1 0 1 0 1 0 1 1
0 1 1 1 0 1 1 1 0 1 1

output:
7 42




'''

