B1, B2, B3 = gets.split.map(&:to_i) a = Rational(B2 - B3, B1 - B2) r = B2 - a * B1 b4 = a * B3 + r puts b4.to_i