#!/usr/bin/env python3 import sys grid = [] for l in sys.stdin: grid.append([int(x) for x in l.strip()]) def lowest(r, c): pt = grid[r][c] if r > 0 and grid[r - 1][c] <= pt: return False if c > 0 and grid[r][c - 1] <= pt: return False if c < 99 and grid[r][c + 1] <= pt: return False if r < 99 and grid[r + 1][c] <= pt: return False return True risk = 0 for r in range(100): for c in range(100): if lowest(r, c): risk += grid[r][c] + 1 print(risk)