#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
} p[300010];
int n, K, S[300010], a[300010];
long long ans;
void read(int &x) {
  char ch = getchar();
  int mark = 1;
  for (; ch != '-' && (ch < '0' || ch > '9'); ch = getchar())
    ;
  if (ch == '-') mark = -1, ch = getchar();
  for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - 48;
  x *= mark;
}
inline bool cmp(point a, point b) {
  if (a.x == b.x) return a.y < b.y;
  return a.x < b.x;
}
int main() {
  read(n);
  read(K);
  for (int i = 1; i <= n; i++) {
    read(p[i].x), read(p[i].y);
    if (p[i].x > p[i].y) swap(p[i].x, p[i].y);
    S[p[i].x]++;
    S[p[i].y]++;
  }
  for (int i = 1; i <= n; i++) a[i] = S[i];
  sort(p + 1, p + n + 1, cmp);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    int t = K - a[i];
    int p = lower_bound(a + i + 1, a + n + 1, t) - a;
    ans += n - p + 1;
  }
  int pre = 0;
  for (int i = 1; i <= n; i++) {
    pre++;
    if (i == n || p[i + 1].x != p[i].x || p[i + 1].y != p[i].y) {
      if (S[p[i].x] + S[p[i].y] >= K && S[p[i].x] + S[p[i].y] - pre < K) ans--;
      pre = 0;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
