#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, y = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') y = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return y ? -x : x;
}
template <typename T>
inline T read() {
  T x = 0;
  int y = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') y = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return y ? -x : x;
}
vector<int> u[300005];
int tax[300005], cnt[300005];
inline void add(int x) { ++tax[++cnt[x]]; }
inline void del(int x) { --tax[cnt[x]--]; }
signed main() {
  int n = read(), p = read();
  long long ans = 0;
  tax[0] = n;
  for (register int i = 1, x, y; i <= n; ++i) {
    x = read(), y = read();
    add(x), add(y), u[x].push_back(y), u[y].push_back(x);
  }
  for (register int i = 1; i <= n; ++i) {
    for (vector<int>::iterator it = u[i].begin(); it != u[i].end(); ++it)
      del(*it);
    ans += tax[max(p - cnt[i], 0)];
    if (cnt[i] >= p - cnt[i]) --ans;
    for (vector<int>::iterator it = u[i].begin(); it != u[i].end(); ++it)
      add(*it);
  }
  printf("%lld\n", ans >> 1);
}
