He had 40-16=<<40-16=24>>24 left after using some
Then after giving some away he is left with 24/2=<<24/2=12>>12
#### 12