class Calc0051 def initialize args = STDIN.readlines.map { |l| l.chomp.split(/\s+/) } @w = args.shift.first.to_i @d = args.shift.first.to_i end def calc w = @w @d.step(2, -1) do |d| w -= Rational(w, d ** 2).floor end w end def run puts calc end end Calc0051.new.run if __FILE__ == $0