9 530792195 6
 0 0 10
 1944219055 454183506 1369298327
 914835 2742837 9234739
 10 10 0
 2 2 0
 0 0 1
 3 10 1007169359
 0 1 0
 1016450951 2 9
 0 2 10
 2147483648 0 2147483647
 92134834 23742837 92374738
 1 4 3
 382601556 881329640 791556039
 0 0 58
 5 10 6
 10 6 8
 6 8 10
 3 2 0
 1 4 4
 2147483630 2147483642 2147483610
 1 0 0
 18 67 5
 50606342 2 1134945035
 8 97 83
 2147483648 0 0
 92134834 23742837 92374737
 5 0 5
 772486757 1747374885 377299255
 1 0 1
 1 2 3
 0 3 2
 2147483648 2147483647 2147483648
 51 10 91
 9214834 2742837 9234739
 1 2 2147483648
 67 81 1
 92134834 23742837 92374739
 2 7 95
 3 0 2
 5 9 0
 1 10 2
 246543403 71853598 1504509195
 2147483648 2147483648 2147483648
 48 6 7
 2147483648 2147483648 0
 1358352906 27037371 1947040615

                                                       530792195
                                                                0
                                                       1944219055
                                                          2742837
                                                               10
                                                                2
                                                                0
                                                       1007169359
                                                                0
                                                       1016450951
                                                                2
 2147483648                                                         92374738
                                                                3
                                                        881329640
                                                                0
                                                               10
                                                                8
                                                                8
                                                                2
                                                                4
                                                       2147483630
                                                                0
                                                               67
                                                         50606342
                                                               97
                                                                0
                                                         92374737
                                                                5
                                                        772486757
                                                                1
                                                                3
                                                                2
 2147483648                                                               91
                                                          9234739
 2147483648                                                               67
                                                         92374739
                                                               95
                                                                2
                                                                9
                                                               10
                                                       1504509195
 2147483648                                                               48
 2147483648                                                       1947040615

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;


public class B {
    
    static StringTokenizer st;
    static BufferedReader in;
    static PrintWriter pw;
    static Map<Long, Integer> map;
    static long p = (long) (1e10+1);
    static long cnt, num;
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        long a = nextLong();
        long b = nextLong();
        long c = nextLong();
        if (a==0 && b==0 || a==0 && c==0 || b==0 && c==0) {
            System.out.println(0);
            return;
        }
        long ans = (long) 1e18;
        map = new HashMap<Long, Integer>();
        if (a != 0 && b != 0) {
            long min = Math.min(a, b);
            cnt = min;
            go(a-min, b-min, c+2*min);
            ans = Math.min(ans, cnt);
        }
        if (a != 0 && c != 0) {
            long min = Math.min(a, c);
            cnt = min;
            num = 0;
            go(a-min, b+2*min, c-min);
            ans = Math.min(ans, cnt);
        }
        if (b != 0 && c != 0) {
            long min = Math.min(b, c);
            cnt = min;
            num = 0;
            go(a+2*min, b-min, c-min);
            ans = Math.min(ans, cnt);
        }
        if (ans==1e18)
            System.out.println(-1);
        else
            System.out.println(ans);
        pw.close();
    }
    private static void go(long a, long b, long c) {
        long hash = a + b*p + c*p*p;
        if (map.containsKey(hash)) {
            cnt = (long) 1e18;
            return;
        }
        if (num > 1e5) {
            cnt = (long) 1e18;
            return;
        }
        if (a==0 && b==0 || a==0 && c==0 || b==0 && c==0) {
            return;
        }
        else {
            if (a != 0 && b != 0) {
                long min = Math.min(a, b);
                cnt += min;
                num++;
                go(a-min, b-min, c+2*min);
            }
            if (a != 0 && c != 0) {
                long min = Math.min(a, c);
                cnt += min;
                num++;
                go(a-min, b+2*min, c-min);
            }
            if (b != 0 && c != 0) {
                long min = Math.min(b, c);
                cnt += min;
                num++;
                go(a+2*min, b-min, c-min);
            }
        }
        map.put(hash, 0);
    }
    private static int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
    
    private static long nextLong() throws IOException{
        return Long.parseLong(next());
    }
    
    private static double nextDouble() throws IOException{
        return Double.parseDouble(next());
    }
    
    private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
}
