If two lengths differed by at least two, replacing two deepest sibling leaves by their parent and splitting a shallower leaf lowers total length, contradicting optimality. Thus lengths are b=⌊log2m⌋ and b+1. Kraft equality gives nb=2b+1−m and nb+1=2m−2b+1, hence