use strict; use warnings; my $line = <>; chomp $line; unless (length $line) { print 0; exit; } my @arr = split //,$line; my $max = 0; for (my $cent = 0; $cent < scalar @arr; $cent++) { my $count = 1; for (my $i = 1; ; $i++) { my $left = $cent - $i; my $right = $cent + $i; last if $left < 0; last if $right >= scalar @arr; $count++ if $arr[$left] eq $arr[$right]; } $max = $count if $max < $count; $count = 0; for (my $i = 1; ; $i++) { my $left = $cent; my $right = $cent + $i; last if $left < 0; last if $right >= scalar @arr; $count++ if $arr[$left] eq $arr[$right]; } $max = $count if $max < $count; } print $max;