let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let xs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun x -> x in
  let count = Array.make m 0 in
  let pairs = Array.make m 0 in
  begin
    let elt = Array.make 100001 false in
    Array.iter (fun x ->
      (if elt.(x) then pairs.(x mod m) <- 1 + pairs.(x mod m));
      elt.(x) <- not elt.(x);
      count.(x mod m) <- 1 + count.(x mod m)) xs
  end;
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 @@ 
  Array.init m @@ fun i ->
    if m - i < i then 0
    else if i = 0 || m - i = i then count.(i) / 2
    else begin
      let x = min count.(i) count.(m - i) in
      x
      + min (count.(i) - x) (2 * pairs.(i)) / 2
      + min (count.(m - i) - x) (2 * pairs.(m - i)) / 2
    end
