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.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.List;
 import java.util.*;
 public class realfast implements Runnable 
  {
    private static final int INF = (int) 1e9;
    long in= 998244353;
    long fac[]= new long[3000];
    public  void solve() throws IOException 
    {
        
         int n = readInt();
         int p = readInt();
         int deg[]=new int[n+1];
         int ins[]= new int[n+1];
         int a[]=new int[n+1];
         int b[]= new int[n+1];

         for(int i=1;i<=n;i++)
         {
            a[i]= readInt();
            b[i]= readInt();
            deg[a[i]]++;
            deg[b[i]]++;
         }

         for(int i=1;i<=n;i++)
          ins[i]= deg[i];

       //  int j =n;

         Arrays.sort(ins);

         int j=n;
         long ans =0;
         for(int i=1;i<=n;i++)
         {
             while(j>i&&ins[i]+ins[j]>=p)
             {
                 j--;
             }
             //out.println(j+"   ");
             if(j==i)
             {

                  long count = n-i;
                 ans= ans+ (count*(count+1))/2;
                 break; 
             }
             else
                ans=ans+n-j;
         }     

         HashMap<String ,Integer> map = new HashMap<>();
         int count[]=new int[n+1];
         
         for(int i=1;i<=n;i++)
         {
            int min =Math.min(a[i],b[i]);
            int max = a[i]+b[i]-min;
            String s= min+" "+max;
            count[i]=1;
            if(map.containsKey(s))
            {
               count[i]=map.get(s)+1;
                map.put(s,map.get(s)+1);
            }
            else
                map.put(s,1);
         }  
         // out.println(ans);
         //for(int i=1;i<=n;i++)
         //{
          //  out.print(ins[i]+" ");
        // }
         //out.println();
         for(int i =1;i<=n;i++)
         {
            int min =Math.min(a[i],b[i]);
            int max = a[i]+b[i]-min;
            String s= min+" "+max;
            int val = map.get(s);

            if(val==count[i])
            {
                int gal = deg[min]+deg[max]-val;
                if(deg[min]+deg[max]>=p&&deg[min]+deg[max]-val<p)
                {
                   // out.println(min+" "+max);
                    ans--;
                }
            }

         }
         out.println(ans);


        
    }
    public int build(int seg[] , int left, int right , int index , int sum[])
    {
             if(left==right)
             {
                seg[index]= sum[left];
                return seg[index];
             }
             int mid = left +(right-left)/2;
             int left1 = build(seg, left,mid,2*index+1,sum);
             int right1 = build(seg,mid+1,right, 2*index+2,sum);
             seg[index]=Math.max(left1,right1);
             return seg[index];
    }
    public int value (int seg[], int left , int right ,int index, int l, int r)
    {
            
            if(left>right)
            {
              return -100000000;
            }
            if(right<l||left>r)
                return -100000000;
            if(left>=l&&right<=r)
                return seg[index];
            int mid = left+(right-left)/2;
            int val = value(seg,left,mid,2*index+1,l,r);
            int val2 = value(seg,mid+1,right,2*index+2,l,r);
            return Math.max(val,val2);

    }
   
    public int gcd(int a , int b )
    {
      if(a<b)
      {
        int t =a;
        a=b;
        b=t;
      }
      if(a%b==0)
        return b ;
      return gcd(b,a%b);
    }
    public long pow(long n , long p,long m)
    {
         if(p==0)
            return 1;
        long val = pow(n,p/2,m);;
        val= (val*val)%m;
        if(p%2==0)
            return val;
        else
            return (val*n)%m;
    }
    
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public static void main(String[] args) {
        new Thread(null, new realfast(), "", 128 * (1L << 20)).start();
    }
 
    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    private PrintWriter out;
 
    @Override
    public void run() {
        try {
            if (ONLINE_JUDGE || !new File("input.txt").exists()) {
                reader = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                reader = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            }
            solve();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // nothing
            }
            out.close();
        }
    }
 
    private String readString() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
 
    @SuppressWarnings("unused")
    private int readInt() throws IOException {
        return Integer.parseInt(readString());
    }
 
    @SuppressWarnings("unused")
    private long readLong() throws IOException {
        return Long.parseLong(readString());
    }
 
    @SuppressWarnings("unused")
    private double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }
}
class edge implements Comparable<edge>{
    int val ;
    int color;
    
    edge(int u, int v)
    {
       this.val=u;
       this.color=v;
    }
    public int compareTo(edge e)
    {
        return this.val-e.val;
    }
}