#include <bits/stdc++.h>
int st[300001], st1[300001];
void solve(int n) {
  int i, l, m, r, j, a, b, p;
  long long int res = 0;
  std::vector<std::vector<int>> v(n);
  std::vector<int> one;
  scanf("%d", &p);
  for (i = 0; i < n; i++) st[i] = 0;
  for (i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    st[a - 1]++;
    st[b - 1]++;
    if (a > b) {
      v[i].push_back(a - 1);
      v[i].push_back(b - 1);
    } else {
      v[i].push_back(b - 1);
      v[i].push_back(a - 1);
    }
  }
  for (i = 0; i < n; i++) st1[i] = st[i];
  std::sort(st, st + n);
  st[n] = 1000000;
  for (i = 0; i < n; i++) {
    l = i;
    r = n;
    while (l + 1 < r)
      if (st[(l + r) / 2] + st[i] >= p) {
        r = (l + r) / 2;
      } else {
        l = (l + r) / 2;
      }
    res += n - r;
  }
  std::sort(v.begin(), v.end());
  v.push_back(one);
  v[n].push_back(-1);
  v[n].push_back(-1);
  for (i = 0; i < n; i++) {
    m = 1;
    while (v[i][0] == v[i + 1][0] && v[i][1] == v[i + 1][1]) {
      i++;
      m++;
    }
    if (st1[v[i][0]] + st1[v[i][1]] >= p && st1[v[i][0]] + st1[v[i][1]] - m < p)
      res--;
  }
  printf("%I64d\n", res);
}
int main() {
#pragma comment(linker, "/STACK:268435456")
  int k;
  while (scanf("%d", &k) != EOF) {
    solve(k);
  }
  return 0;
}
