use List::Util qw(max); my $input = ; chomp $input; my ($a,$b) = split / /, $input; $ret=$a+$b+max(0,abs($a-$b)-1); print "$ret";