# frozen_string_literal: true w = gets.chomp.to_i d = gets.chomp.to_i (d - 1).times do today = Rational(w / d**2).floor w -= today d -= 1 end puts w