FYI, an easier way to calculate with any large port number would be:

$calc(%port % 65535)

e.g. $calc(765567 % 65535)
That should return: 44671