class Calc0063 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @l, @k = args.shift.map(&:to_i) end def run if @l % (@k * 2) == 0 (@l / (@k * 2) - 1) * @k else @l / (@k * 2) * @k end end end puts Calc0063.new(STDIN.readlines).run if __FILE__ == $0