#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
int f[400000], num[400000];
vector<int> a[400000];
int n, p;
void ins(int x, int y) {
  x++;
  while (x <= n + 1) {
    f[x] += y;
    x += x & -x;
  }
}
int count(int x) {
  int ret = 0;
  x++;
  while (x > 0) {
    ret += f[x];
    x -= x & -x;
  }
  return ret;
}
int main() {
  int i, j, x, y, now;
  scanf("%d%d", &n, &p);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    num[x]++;
    num[y]++;
    a[x].push_back(x);
    a[x].push_back(y);
    a[y].push_back(x);
    a[y].push_back(y);
  }
  for (i = 1; i <= n; i++) ins(num[i], 1);
  long long fin = 0;
  for (i = 1; i <= n; i++) {
    now = a[i].size() / 2;
    for (j = 0; j < a[i].size(); j++) {
      ins(num[a[i][j]], -1);
      num[a[i][j]]--;
      ins(num[a[i][j]], 1);
    }
    fin += n - count(p - now - 1);
    for (j = 0; j < a[i].size(); j++) {
      ins(num[a[i][j]], -1);
      num[a[i][j]]++;
      ins(num[a[i][j]], 1);
    }
  }
  for (i = 1; i <= n; i++)
    if (num[i] >= p) fin--;
  fin /= 2;
  cout << fin << endl;
}
