The number is calculated using Object.keys($input.item.binary).length in the Code node at the end. Object.keys() returns an array of all binary properties of $input.item.binary containing the binary data of an item. .length returns the count.
You can use also use $input.item.binary (or its shorthand form $binary) to read specific properties and apply additional logic to each. You will need to provide the name of the property though if you want to use this in an expression.
Looks like one of your items might not have any attachements @Mike_M. Perhaps you can change the code to account for this scenario, for example like so?