#include <bits/stdc++.h>
using namespace std;
int main() {
  long long breakfast, lunch, dinner;
  long long maxx, minn, middle;
  long long missed = 5000000000000000000;
  cin >> breakfast >> lunch >> dinner;
  minn = min(breakfast, lunch);
  minn = min(maxx, dinner);
  maxx = max(breakfast, lunch);
  maxx = max(maxx, dinner);
  middle = missed;
  missed = min(maxx * 3 - breakfast - lunch - dinner, missed);
  if (missed < 0) missed = middle;
  middle = missed;
  if (breakfast > lunch && breakfast > dinner)
    missed = min(missed, maxx * 3 - 2 - breakfast - lunch - dinner);
  else
    missed = min(missed, maxx * 3 + 1 - breakfast - lunch - dinner);
  if (missed < 0) missed = middle;
  middle = missed;
  if (dinner > lunch && dinner > breakfast)
    missed = min(missed, maxx * 3 + 2 - breakfast - lunch - dinner);
  else
    missed = min(missed, maxx * 3 - 1 - breakfast - lunch - dinner);
  if (missed < 0) missed = middle;
  middle = missed;
  if (dinner > lunch && dinner > breakfast)
    missed = min(missed, maxx * 3 - 2 - breakfast - lunch - dinner);
  else
    missed = min(missed, maxx * 3 + 1 - breakfast - lunch - dinner);
  if (missed < 0) missed = middle;
  middle = missed;
  if (breakfast > lunch && breakfast > dinner)
    missed = min(missed, maxx * 3 + 2 - breakfast - lunch - dinner);
  else
    missed = min(missed, maxx * 3 - 1 - breakfast - lunch - dinner);
  if (missed < 0) missed = middle;
  middle = missed;
  if (lunch > breakfast && lunch > dinner)
    missed = min(missed, maxx * 3 + 2 - breakfast - lunch - dinner);
  else
    missed = min(missed, maxx * 3 - 1 - breakfast - lunch - dinner);
  if (missed < 0) missed = middle;
  middle = missed;
  if (lunch > breakfast && lunch > dinner)
    missed = min(missed, maxx * 3 - 2 - breakfast - lunch - dinner);
  else
    missed = min(missed, maxx * 3 + 1 - breakfast - lunch - dinner);
  if (missed < 0) missed = middle;
  middle = missed;
  cout << missed << endl;
  return 0;
}
