alias LL = Int64 macro chmin(x, y); {{x}} = {{y}} if {{x}} > {{y}}; end macro chmax(x, y); {{x}} = {{y}} if {{x}} < {{y}}; end macro yn(x); {{x}} ? "Yes" : "No"; end # ---------------------------------------------------- :) n, m = read_line.split.map(&.to_i64) a = read_line.split.map(&.to_i64.% m) amax = a.max at = a.tally b = at.to_a.sort_by!{|e| -e[1]} # p! at at.size.times do |i| num, cnt = b[i] next if at[num] == 0 if (num+num) % m == 0 at[num] = 1 next end j = m - num while j <= amax if at[j]? at[j] = 0 end j += m end end # p! at puts at.values.sum