#!/usr/bin/env python3 import sys from collections import defaultdict seen = {} grid = [] for l in sys.stdin: grid.append([int(x) for x in l.strip()]) def search(r, c, color): if (r, c) in seen or grid[r][c] == 9: return seen[(r, c)] = color if r > 0: search(r - 1, c, color) if c > 0: search(r, c - 1, color) if c < 99: search(r, c + 1, color) if r < 99: search(r + 1, c, color) # Search from each point (no-op once seen once)! i = 1 for r in range(100): for c in range(100): search(r, c, i) i += 1 # Finally, count the colors G = defaultdict(int) for v in seen.values(): G[v] += 1 top = sorted(G.values(), reverse=True) print(top[0] * top[1] * top[2])