"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let X = cin.getIntArray(3);
    const div2 = (a) => Math.floor(a / 2);
    let ans = 0;
    while (!X.every(v=>v==X[2])) {
        X.sort((a, b) => a - b);
        let bc = X[2] - X[1];
        if (bc > 0) {
            X[0] += bc;
            X[1] += bc;
            ans += bc;
        }
        let ac = X[2] - X[0];
        if (ac > 0) {
            let a = Math.ceil(ac / 2);
            X[0] += a * 2;
            ans += a;
        }
    }
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));