# Baekjoon-17144-미세먼지 안녕!

import sys
R,C,T = map(int,input().split())
board = [list(map(int,input().split())) for _ in range(R)]
condi = []
for i in range(R):
for j in range(C):
if board[i][j] == -1:
condi.append(i)
condi.sort()

for _ in range(T):
# diffusion
new_board = [[i for i in line] for line in board]
for i in range(R):
for j in range(C):
if board[i][j] > 0:
for ni,nj in [[i+1,j],[i,j+1],[i-1,j],[i,j-1]]:
if 0<=ni<R and 0<=nj<C and board[ni][nj]!=-1:
new_board[ni][nj] += board[i][j]//5
new_board[i][j] -= board[i][j]//5

# conditioning
for i in reversed(range(1,condi[0])):
new_board[i][0] = new_board[i-1][0]
for i in range(condi[1]+1,R-1):
new_board[i][0] = new_board[i+1][0]
for i in range(C-1):
new_board[0][i] = new_board[0][i+1]
new_board[-1][i] = new_board[-1][i+1]
for i in range(condi[0]):
new_board[i][-1] = new_board[i+1][-1]
for i in reversed(range(condi[1]+1,R)):
new_board[i][-1] = new_board[i-1][-1]
for i in reversed(range(2,C)):
new_board[condi[0]][i] = new_board[condi[0]][i-1]
new_board[condi[1]][i] = new_board[condi[1]][i-1]
new_board[condi[0]][1] = 0
new_board[condi[1]][1] = 0

board = new_board

result = 0
for i in range(R):
for j in range(C):
if board[i][j] > 0:
result += board[i][j]
print(result)