#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int n, p;
int cnt[N], d[N];
int x[N], y[N];
map<int, int> g[N];
void print(int *a, int b, int e) {
  for (int i = b; i <= e; ++i) {
    printf("%d ", a[i]);
  }
  putchar('\n');
}
int main() {
  scanf("%d%d", &n, &p);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", x + i, y + i);
    cnt[x[i]]++;
    cnt[y[i]]++;
    g[x[i]][y[i]]++;
    g[y[i]][x[i]]++;
  }
  for (int i = 1; i <= n; ++i) {
    d[cnt[i]]++;
  }
  for (int i = n - 1; i >= 1; --i) {
    d[i] += d[i + 1];
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    int cntbig = 0;
    int need = p - cnt[i];
    if (need <= 0) {
      ans += n - 1;
      continue;
    }
    cntbig += cnt[i] >= need;
    for (auto kv : g[i]) {
      if (cnt[kv.first] + cnt[i] - kv.second >= p) {
        ++ans;
      }
      cntbig += cnt[kv.first] >= need;
    }
    ans += d[need] - cntbig;
  }
  printf("%lld\n", ans / 2);
  return 0;
}
