#include <bits/stdc++.h>
using namespace std;
long long i, j, k, l, ii, t, m, h, s, n, a[311111], b[311111], c[311111],
    d[311111], e;
string p;
char q, r;
map<long long, long long> y;
int main() {
  cin >> n >> l;
  h = 1000000;
  for (i = 0; i < n; i++) {
    scanf("%I64d%I64d", &k, &m);
    a[k]++;
    a[m]++;
    if (k > m) swap(k, m);
    c[i] = k * h + m;
    y[k * h + m]++;
  }
  for (i = 1; i <= n; i++) {
    b[i - 1] = a[i];
  }
  sort(b, b + n);
  k = n - 1;
  for (i = 0; i < n - 1; i++) {
    k = max(i + 1, k);
    while (b[k] + b[i] >= l && k > i) k--;
    s += n - 1 - k;
  }
  for (i = 0; i < n; i++) {
    k = c[i] / h;
    m = c[i] % h;
    if (a[k] + a[m] - y[c[i]] < l && a[k] + a[m] >= l) {
      s--;
      y[c[i]] = 0;
    }
  }
  cout << s;
}
