We have an array of positive numbers. We repeatedly apply the following operation to the array until fewer than two elements remain:
Select two elements with the smallest absolute difference. If there are several such pairs, choose the pair with the smallest sum. If there are still multiple pairs, choose any of them.
Decrease each of the selected elements by .
Remove any elements that have become zero from the array.
It is clear that this process ends after a finite number of steps.
For example, given the array \{3, 2, 3, 2\} with elements, the transformation process is as follows:
Step : \{3, 2, 3, 2\} \Rightarrow \{3, 1, 3, 1\} (decrease elements and )
Step : \{3, 1, 3, 1\} \Rightarrow \{3, 3\} (after decrease, elements and are removed)
Step : \{3, 3\} \Rightarrow \{2, 2\}
Step : \{2, 2\} \Rightarrow \{1, 1\}
Step : \{1, 1\} \Rightarrow \{\}
We obtain an empty array. Determine the number of transformation steps.
A single line contains a sequence of numbers separated by commas and spaces, ending with a period. The array contains between and elements, and each element is between and inclusive.
Output the number of transformation steps for the given array.
Example 1