import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.HashSet; import java.util.Set; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int m = Integer.parseInt(sa[1]); sa = br.readLine().split(" "); int[] a = new int[n]; Set set = new HashSet<>(); for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); set.add(a[i]); } br.close(); if (m % 2 == 1) { System.out.println(0); return; } long ans = 0; int m2 = m / 2; for (int i = 0; i < n; i++) { int v = a[i] + m2; v %= m; if (v == 0) { v = m; } if (set.contains(v)) { ans += n - 2; } } System.out.println(ans / 2); } }