object Main extends App{
  import scala.io.StdIn._

  val (min::mid::max::_) =  readLine().trim().split(' ').map(_.toInt).sorted.toList
  def solve(min:Int, mid:Int, max:Int):Int = {
    if (min == mid && mid == max)
      0
    else if (max - min == 1) {
      if (max == mid) 2
      else 1
    }else{
      if (mid - min >= 2){
        solve(min + 2, mid, max) + 1
      }else{
        solve(mid, min + 2, max) + 1
      }
    }
  }
  println(solve(min, mid, max))
}