@S=<>=~/./g; for$l(0..$#S){ for$r($l..$#S-!$l){ if(@S[$l..$r]~~@S[reverse$l..$r]){ $%+=$-=$r-$l+1-$% } } } print$%