H, A = gets.split.map(&:to_i) slimes = [H] count = 0 until slimes.empty? slime, *slimes = slimes slimes << slime / A slimes << slime / A slimes.select! { _1 > 0 } count += 1 end puts count