m, n = gets.split.map(&:to_i) count = 0 until m == n if m < n t = n n = m m = t count += 1 else if m % n == 0 count += (m / n - 1) m = n else count += (m / n) m = (m % n) end end end puts count