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 isSquareBorder
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 isSquareBorder(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 isOkSquareInterior(yul, xul, ybr, xbr):
    count0 = 0
    for row in range (yul+1, ybr):
        for col in range( xul+1, xbr):
            if matrix[row][col] == 0:
                count0 += 1
                if count0 >= 2:
                    return False
    return True

def isCorrectSquare(yul, xul, ybr, xbr):
    return \
           isSquareBorder     (yul-1, xul-1, ybr+1, xbr+1, 0)  \
       and isSquareBorder     (yul,   xul,   ybr,   xbr,   1)  \
       and isOkSquareInterior (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-1][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
                # possible upper right corner found,
                # its x-coord belongs also to bottom right corner
                size = x - xul
                xbr = xul + size - 1
                ybr = yul + size - 1
                if ybr > M:
                    continue
                if isCorrectSquare(yul, xul, ybr, xbr):
                    count += 1
                    area += size**2
    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




'''

