function Main(input) {
    input = input.trim();
    input = input.split(" ");
    var a = input[0];
    var b = input[1];
    var c = input[2];

    var result = 0;



    if ((c - b) % 2 == 0) {
        result = (c - b) / 2;
        if ((b + c - 2) >= 0) {
            result = Math.min(result, (b + c - 2) / 2);
        }
        if ((2 * a - b - c) >= 0) {
            result = Math.min(result, (2 * a - b - c) / 2);
        }
    } else {
        var d = a - b;
        var e = c - 1;
        result = Math.min(d, e);

        if (((a - c) + 1 + (a - b)) >= 0) {
            result = Math.min(result, ((a - c) + 1 + (a - b)) / 2);
        }

        if ((c + b - 1) >= 0) {
            result = Math.min(result, ((b - 1) + c) / 2);
        }        

    }




    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 