#!/usr/bin/perl -w

use v5.36;
use strict;
use experimental 'multidimensional';
use List::Util qw(none);

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 $count = sub {
		my $c = 0;
		for (@_) {
			$c++;
			last if $m[$_->[1]][$_->[0]] >= $m[$y][$x];
		}
		$c;
	};
	my $score = $count->( map { [ $_, $y ] } reverse 0 .. $x-1 )
		  * $count->( map { [ $_, $y ] } $x+1 .. $xmax-1)
		  * $count->( map { [ $x, $_ ] } reverse 0 .. $y-1)
		  * $count->( map { [ $x, $_ ] } $y+1 .. $ymax-1)
	;
	$max = $score if $max < $score;
} }

say $max;

