/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		a[i]=sc.nextInt();
		
		Map<Integer,Integer> hash=new HashMap<>();
		
		int count=0;
		for(int ele:a)
		{
			int cpl1=k-ele;
			int cpl2=k+ele;
			
			if(hash.containsKey(cpl1 ))
			count+=hash.get(cpl1);
			if(hash.containsKey(cpl2))
			count+=hash.get(cpl2);
			
			hash.put(ele,hash.getOrDefault(ele,0)+1);
		}
		
		System.out.println(count);
		
	}
}