#include <bits/stdc++.h>
using namespace std;
long long int bit[300051];
int ctr[300051];
set<int> store[300051];
pair<int, int> a[300051];
map<pair<int, int>, int> m;
void update(int ind, int val) {
  ind += 5;
  while (ind <= 300051) {
    bit[ind] += val;
    ind += (ind & -ind);
  }
}
long long int query(int ind) {
  long long int sum = 0;
  ind += 5;
  while (ind > 0) {
    sum += bit[ind];
    ind -= (ind & -ind);
  }
  return sum;
}
int main() {
  int i, j, n, req, x, y;
  long long int ans = 0, got = 0;
  scanf("%d%d", &n, &req);
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].first, &a[i].second);
    if (a[i].first > a[i].second) swap(a[i].first, a[i].second);
    m[make_pair(a[i].first, a[i].second)]++;
    ctr[a[i].first]++;
    ctr[a[i].second]++;
    store[a[i].first].insert(a[i].second);
    store[a[i].second].insert(a[i].first);
  }
  for (i = 1; i <= n; i++) update(ctr[i], 1);
  for (i = 1; i <= n; i++) {
    update(ctr[i], -1);
    for (auto it : store[i]) update(ctr[it], -1);
    ans += query(300051 - 5);
    if (req - ctr[i] - 1 >= 0)
      ;
    ans -= query(req - ctr[i] - 1);
    update(ctr[i], 1);
    for (auto it : store[i]) update(ctr[it], 1);
    for (auto it : store[i]) {
      x = i;
      y = it;
      got = ctr[x] + ctr[y];
      if (x > y) swap(x, y);
      got -= m[make_pair(x, y)];
      if (got >= req) ans++;
    }
  }
  printf("%lld", ans / 2);
  return 0;
}
