Oil gains as US inventories grow less than feared