#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, p;
  cin >> n >> p;
  vector<map<int, int>> commons(n);
  vector<int> weights(n);
  for (int i = 0; i < n; ++i) {
    int a1, a2;
    cin >> a1 >> a2;
    ++weights[a1 - 1];
    ++weights[a2 - 1];
    ++commons[a1 - 1][a2 - 1];
    ++commons[a2 - 1][a1 - 1];
  }
  vector<pair<int, int>> newOrder(n);
  for (int i = 0; i < n; ++i) {
    newOrder[i].first = weights[i];
    newOrder[i].second = i;
  }
  sort(newOrder.rbegin(), newOrder.rend());
  vector<int> newIds(n);
  for (int i = 0; i < n; ++i) {
    newIds[newOrder[i].second] = i;
    weights[i] = newOrder[i].first;
  }
  int start = 0;
  int end = n - 1;
  long long sum = 0;
  while (start < end) {
    if (weights[start] + weights[end] < p) {
      --end;
      continue;
    }
    sum += end - start;
    for (auto it = commons[newOrder[start].second].begin();
         it != commons[newOrder[start].second].end(); ++it) {
      if (newIds[it->first] > start && newIds[it->first] <= end &&
          weights[start] + weights[newIds[it->first]] - it->second < p)
        --sum;
    }
    ++start;
  }
  cout << sum << endl;
}
