Let $S$ be a real number. It is known that however we choose several numbers from the interval $(0, 1]$ with sum equal to $S$, these numbers can be separated into two subsets with the following property: The sum of the numbers in one of the subsets doesn’t exceed 1 and the sum of the numbers in the other subset doesn’t exceed 5. 

Find the greatest possible value of $S$.