object Main extends App {	
  val in = readLine.split(" ").map(_.toInt).toList.sorted
  
  def seracheCost(list: List[Int], exe: Int, count: Int): Int = list match {
  	case Nil => count
    case head :: tail => seracheCost(tail, head, count + head - exe)
  }
  
  println(seracheCost(in.tail, in.head, 0))
}