Recently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code? Each of the n coders on the meeting said: 'I know for sure that either x or y did it!'

The head of the company decided to choose two suspects and invite them to his office. Naturally, he should consider the coders' opinions. That's why the head wants to make such a choice that at least p of n coders agreed with it. A coder agrees with the choice of two suspects if at least one of the two people that he named at the meeting was chosen as a suspect. In how many ways can the head of F choose two suspects?

Note that even if some coder was chosen as a suspect, he can agree with the head's choice if he named the other chosen coder at the meeting.

Input

The first line contains integers n and p (3 ≤ n ≤ 3·105; 0 ≤ p ≤ n) — the number of coders in the F company and the minimum number of agreed people.

Each of the next n lines contains two integers xi, yi (1 ≤ xi, yi ≤ n) — the numbers of coders named by the i-th coder. It is guaranteed that xi ≠ i, yi ≠ i, xi ≠ yi.

Output

Print a single integer –– the number of possible two-suspect sets. Note that the order of the suspects doesn't matter, that is, sets (1, 2) и (2, 1) are considered identical.

Examples

Input

4 2
2 3
1 4
1 4
2 1


Output

6


Input

8 6
5 6
5 7
5 8
6 2
2 1
7 3
1 3
1 4


Output

1
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Solver {

	public static void main(String[] Args) throws NumberFormatException,
			IOException {
		new Solver().Run();
	}

	PrintWriter pw;
	StringTokenizer Stok;
	BufferedReader br;

	public String nextToken() throws IOException {
		while (Stok == null || !Stok.hasMoreTokens()) {
			Stok = new StringTokenizer(br.readLine());
		}
		return Stok.nextToken();
	}

	public int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}

	class TEmp{
		int ind;
		int kolFound;
		
		public TEmp(int aInd){
			ind=aInd;
			kolFound=0;
		}
	}
	
	final long shift=400000;
	int n,p;
	TEmp[] emps;
	int[] kolFound;
	long[][] data;
	long result=0;
	
	public void Run() throws NumberFormatException, IOException {
		//br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter("output.txt");
		br=new BufferedReader(new InputStreamReader(System.in));  pw=new PrintWriter(new OutputStreamWriter(System.out));
		
		n=nextInt();
		p=nextInt();
		emps=new TEmp[n];
		kolFound=new int[n];
		for (int i=0; i<n; i++){
			emps[i]=new TEmp(i);
		}
		data=new long[n][2];
		for (int i=0; i<n; i++){
			data[i][0]=nextInt()-1;
			data[i][1]=nextInt()-1;
			if (data[i][0]>data[i][1]){
				long buf=data[i][0];
				data[i][0]=data[i][1];
				data[i][1]=buf;
			}
			emps[(int) data[i][0]].kolFound++;
			emps[(int) data[i][1]].kolFound++;
			kolFound[(int) data[i][0]]++;
			kolFound[(int) data[i][1]]++;
		}
		Arrays.sort(emps, new Comparator<TEmp>(){

			@Override
			public int compare(TEmp arg0, TEmp arg1) {
				return arg1.kolFound-arg0.kolFound;
			}
			
		});
		
		int ind1=0, ind2=n-1;
		while (ind1<n && emps[ind1].kolFound>=p){
			result+=(n-ind1-1);
			ind1++;
		}
		while (ind1<ind2){
			while (ind2>ind1 && emps[ind2].kolFound+emps[ind1].kolFound<p)
				ind2--;
			if (ind2>ind1){
				result+=(ind2-ind1);
			}
			ind1++;
		}
		
		Map<Long, Integer> map=new TreeMap<Long, Integer>();
		for (int i=0; i<n; i++){
			Integer buf=map.get(data[i][0]*shift+data[i][1]);
			int zn=(buf==null)?0:(int)buf;
			if (kolFound[(int) data[i][0]]+kolFound[(int) data[i][1]]-zn==p)
				result--;
			zn++;
			map.put(data[i][0]*shift+data[i][1], zn);
			
		}
		pw.println(result);
		pw.flush();
		pw.close();
	}

}
