#include <bits/stdc++.h>
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  size_t n, p;
  std::cin >> n >> p;
  std::vector<size_t> counts(n);
  std::vector<std::map<size_t, size_t>> pairs(n);
  for (size_t i = 0; i < n; ++i) {
    size_t x, y;
    std::cin >> x >> y;
    x -= 1;
    y -= 1;
    counts[x] += 1;
    counts[y] += 1;
    pairs[x][y] += 1;
    pairs[y][x] += 1;
  }
  auto order = counts;
  sort(order.begin(), order.end());
  uint64_t result = 0;
  for (size_t i = 0; i < n; ++i) {
    if (counts[i] >= p) {
      result += n - 1;
    } else {
      result +=
          order.end() - lower_bound(order.begin(), order.end(), p - counts[i]);
      if (p - counts[i] <= counts[i]) {
        result -= 1;
      }
    }
    for (const auto& [k, v] : pairs[i]) {
      if (counts[i] + counts[k] >= p && counts[i] + counts[k] < p + v) {
        result -= 1;
      }
    }
  }
  result /= 2;
  std::cout << result << '\n';
}
