#!/usr/bin/perl -w

use v5.36;
use strict;
use experimental 'multidimensional';

my @m = map { chomp; [ split // ] } <>;
my $xmax = @{ $m[0] };
my $ymax = @m;

my $max = 0;
for my $y (1 .. $ymax-2) {
for my $x (1 .. $xmax-2) {
	my $h = $m[$y][$x];
	my $mul = 1;
	my $count = 0;
	for my $dx (reverse (0 .. $x-1)) {
		$count++;
		last if $m[$y][$dx] >= $h;
	}
	$mul *= $count;

	$count = 0;
	for my $dx ($x+1 .. $xmax-1) {
		$count++;
		last if $m[$y][$dx] >= $h;
	}
	$mul *= $count;

	$count = 0;
	for my $dy (reverse 0 .. $y-1) {
		$count++;
		last if $m[$dy][$x] >= $h;
	}
	$mul *= $count;

	$count = 0;
	for my $dy ($y+1 .. $ymax-1) {
		$count++;
		last if $m[$dy][$x] >= $h;
	}
	$mul *= $count;
	# say "$x $y $h $mul";

	$max = $mul if $max < $mul;

} }

say $max;
