You are playing a solitaire game with three piles of stones of sizes a​​​​​​, b,​​​​​​ and c​​​​​​ respectively. Each turn you choose two different non-empty piles, take one stone from each, and add 1 point to your score. The game stops when there are fewer than two non-empty piles (meaning there are no more available moves).

Given three integers a​​​​​, b,​​​​​ and c​​​​​, return the maximum score you can get.

&nbsp;
Example 1:

Input: a = 2, b = 4, c = 6
Output: 6
Explanation: The starting state is (2, 4, 6). One optimal set of moves is:
- Take from 1st and 3rd piles, state is now (1, 4, 5)
- Take from 1st and 3rd piles, state is now (0, 4, 4)
- Take from 2nd and 3rd piles, state is now (0, 3, 3)
- Take from 2nd and 3rd piles, state is now (0, 2, 2)
- Take from 2nd and 3rd piles, state is now (0, 1, 1)
- Take from 2nd and 3rd piles, state is now (0, 0, 0)
There are fewer than two non-empty piles, so the game ends. Total: 6 points.


Example 2:

Input: a = 4, b = 4, c = 6
Output: 7
Explanation: The starting state is (4, 4, 6). One optimal set of moves is:
- Take from 1st and 2nd piles, state is now (3, 3, 6)
- Take from 1st and 3rd piles, state is now (2, 3, 5)
- Take from 1st and 3rd piles, state is now (1, 3, 4)
- Take from 1st and 3rd piles, state is now (0, 3, 3)
- Take from 2nd and 3rd piles, state is now (0, 2, 2)
- Take from 2nd and 3rd piles, state is now (0, 1, 1)
- Take from 2nd and 3rd piles, state is now (0, 0, 0)
There are fewer than two non-empty piles, so the game ends. Total: 7 points.


Example 3:

Input: a = 1, b = 8, c = 8
Output: 8
Explanation: One optimal set of moves is to take from the 2nd and 3rd piles for 8 turns until they are empty.
After that, there are fewer than two non-empty piles, so the game ends.


&nbsp;
Constraints:


	1 &lt;= a, b, c &lt;= 105


class Solution:
    def maximumScore(self, a: int, b: int, c: int) -> int:
        a, b, c = sorted([a, b, c], reverse=True)
        ans = 0
        while a > 0 and b > 0:
            a -= 1
            b -= 1
            ans += 1
            a, b, c = sorted([a, b, c], reverse=True)
        return ans
class Solution {
    public int maximumScore(int a, int b, int c) {
        // Make sure a <= b <= c
        if (a>b) return maximumScore(b,a,c);
        if (b>c) return maximumScore(a,c,b);
        
        // if sum of smallest numbers [a+b] is less than c, then we can a + b pairs with the c
        if (a+b<=c) return a+b;
        
        // if sum of smallest numbers is greater than c, then we can (a+b)/2 pairs after making c empty
        return c+(a+b-c)/2;
    }
}
class Solution {
public:
    int maximumScore(int a, int b, int c) {
        return min((a + b + c) / 2, a + b + c - max({a, b, c}));
    }
};
/**
 * @param {number} a
 * @param {number} b
 * @param {number} c
 * @return {number}
 */
var maximumScore = function(a, b, c) {
    let resultArray = [];
    resultArray.push(a);
    resultArray.push(b);
    resultArray.push(c);
    resultArray.sort((a,b)=>a-b);
    let counter=0;
    while(resultArray[0]>0||resultArray[1]>0||resultArray[2]>0){
        if(resultArray[0]===0&&resultArray[1]===0){
            break;
        }
        resultArray[1]--;
        resultArray[2]--;
        counter++
        if(resultArray[1]<resultArray[0]){
            exchange(resultArray,1,0);
        }
        if(resultArray[2]<resultArray[0]){
            exchange(resultArray,2,0);
        }
    }
    if(resultArray[0]+resultArray[1]+resultArray[2]===0) return counter;
    if(resultArray[0]<0||resultArray[1]<0||resultArray[2]<0) counter--;
    return counter;

    function exchange(array, indexa,indexb){
        let temp = array[indexa];
        array[indexa] = array[indexb];
        array[indexb] = temp;
    }

};
Maximum Score From Removing Stones