$/=+<>.words;$1.permutations.map({sum 0 Xmax(@$_ Z-@$2)}).Bag.max.value.say