#include <iostream>

int main() {
    int A, B, C;
    std::cin >> A >> B >> C;
    if ((A + B + C) % 3 != 0) {
        std::cout << "-1\n";
    } else {
        int avg = (A + B + C) / 3;
        std::cout << (abs(A - avg) + abs(B - avg) + abs(C - avg)) / 2 << "\n";
    }
}
