$/=words;say $0-($_=max $4-$1,0)+min $_+$2,$5