#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> s;
int x[333333], y[333333], cnt[333333], f[333333], a, b, n, p, k;
long long res;
int main() {
  scanf("%d%d", &n, &p);
  for (int i = (1), _b = (n); i <= _b; i++) {
    cin >> x[i] >> y[i];
    cnt[x[i]]++;
    cnt[y[i]]++;
    if (x[i] > y[i]) swap(x[i], y[i]);
    s[make_pair(x[i], y[i])]++;
  }
  for (int i = (1), _b = (n); i <= _b; i++) f[cnt[i]]++;
  for (int i = (n), _a = (0); i >= _a; i--) f[i] = f[i + 1] + f[i];
  for (int i = (1), _b = (n); i <= _b; i++) {
    k = max(0, p - cnt[i]);
    int tmp = f[k];
    if (k <= cnt[i]) tmp--;
    res = res + tmp;
  }
  for (int i = (1), _b = (n); i <= _b; i++) {
    a = x[i];
    b = y[i];
    if (cnt[a] + cnt[b] >= p && cnt[a] + cnt[b] - s[make_pair(a, b)] < p)
      res = res - 2;
    s[make_pair(a, b)] = 0;
  }
  res = res / 2;
  cout << res;
  return 0;
}
