#include <bits/stdc++.h>
const int inf = 0xfffffff;
const long long INF = 1ll << 61;
using namespace std;
int n, p;
map<pair<int, int>, int> mp;
map<pair<int, int>, int>::iterator pp;
int du[300000 + 55];
void init() {
  mp.clear();
  memset(du, 0, sizeof(du));
}
bool input() {
  while (cin >> n >> p) {
    int q = n;
    while (q--) {
      int x, y;
      scanf("%d %d", &x, &y);
      if (x > y) swap(x, y);
      du[x]++;
      du[y]++;
      mp[make_pair(x, y)]++;
    }
    return false;
  }
  return true;
}
void cal() {
  long long ans = 0;
  for (pp = mp.begin(); pp != mp.end(); pp++) {
    int t1 = pp->first.first;
    int t2 = pp->first.second;
    if (du[t1] + du[t2] >= p && du[t1] + du[t2] - pp->second < p) ans--;
  }
  sort(du + 1, du + n + 1);
  for (int i = 1; i < n; i++) {
    if (du[i] >= p) {
      ans += (n - i);
      continue;
    }
    int tmp = p - du[i];
    if (tmp > du[n]) continue;
    int pos = lower_bound(du + i + 1, du + 1 + n, tmp) - du;
    ans += (n - pos + 1);
  }
  cout << ans << endl;
}
void output() {}
int main() {
  while (true) {
    init();
    if (input()) return 0;
    cal();
    output();
  }
  return 0;
}
