#! ruby L, K = gets.chomp.split.map(&:to_i) K2 = K * 2 rem = L % K2 yuu = ((L - rem) / K2) * K puts yuu