#include <bits/stdc++.h>
using namespace std;
const int N = 300500;
int n, p;
vector<int> g[N];
int cnt[N];
int sorted_cnt[N];
int gr_eq_than[N];
int main() {
  scanf("%d%d", &n, &p);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
    cnt[x]++;
    cnt[y]++;
  }
  for (int i = 0; i < n; i++) sort(g[i].begin(), g[i].end());
  copy(cnt, cnt + n, sorted_cnt);
  sort(sorted_cnt, sorted_cnt + n);
  int ptr = n;
  for (int i = N - 1; i >= 0; i--) {
    while (ptr - 1 >= 0 && sorted_cnt[ptr - 1] >= i) ptr--;
    gr_eq_than[i] = n - ptr;
  }
  long long answer = 0;
  for (int i = 0; i < n; i++) {
    int delta = p - cnt[i];
    if (delta < 0) {
      answer += n - 1;
      continue;
    }
    int bad = 0;
    if (cnt[i] >= delta) bad++;
    int ptr = 0;
    for (int j = (g[i].empty() ? 1 : 0); j <= g[i].size(); j++)
      if (j == g[i].size() || g[i][j] != g[i][ptr]) {
        int cur_block = j - ptr;
        if (cnt[g[i][ptr]] >= delta && cnt[g[i][ptr]] - cur_block < delta)
          bad++;
        ptr = j;
      }
    int good = gr_eq_than[delta];
    answer += good - bad;
  }
  printf("%I64d\n", answer / 2);
  return 0;
}
