#include <bits/stdc++.h>
using namespace std;
const int N = 3 * 100111;
vector<vector<int> > adj;
int bl[N];
int hbl[N];
int shbl[N];
int dbl[N];
int main() {
  int n, p;
  cin >> n >> p;
  adj.resize(n);
  int a, b;
  for (int i = 0; i < (n); ++i) {
    cin >> a >> b;
    --a;
    --b;
    adj[a].push_back(b);
    adj[b].push_back(a);
    bl[a]++;
    bl[b]++;
  }
  for (int i = 0; i < (n); ++i) hbl[bl[i]]++;
  shbl[n - 1] = hbl[n - 1];
  for (int i = n - 2; i >= 0; --i) shbl[i] = hbl[i] + shbl[i + 1];
  long long ans = 0;
  int cans;
  for (int i = 0; i < (n); ++i) {
    int pm = p - bl[i];
    if (pm <= 0)
      ans += n - 1;
    else {
      cans = shbl[pm];
      if (bl[i] >= pm) cans--;
      for (int j = 0; j < (adj[i].size()); ++j) dbl[adj[i][j]]--;
      for (int j = 0; j < (adj[i].size()); ++j) {
        int v = adj[i][j];
        if (bl[v] >= pm && bl[v] + dbl[v] < pm) --cans;
        dbl[v] = 0;
      }
      ans += cans;
    }
  }
  cout << ans / 2 << "\n";
  return 0;
}
