MN = gets.split.map(&:to_i) count = 0 until MN[0] == MN[1] if MN[0] < MN[1] MN.reverse! count += 1 elsif MN[0] % MN[1] == 0 count += (MN[0] / MN[1] - 1) break else count += (MN[0] / MN[1]) MN[0] %= MN[1] end end puts count