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