#include <bits/stdc++.h>
using namespace std;
class Node {
 public:
  long long p, v;
  Node(long long p, long long v = 0) : p(p), v(v) {}
};
int main() {
  long long n, p;
  cin >> n >> p;
  unordered_map<long long, long long> m;
  vector<Node> v;
  vector<Node> ori;
  ori.reserve(n);
  v.reserve(n);
  for (__typeof(n) i = 0; i < (n); ++i) {
    v.push_back(Node(i));
    ori.push_back(Node(i));
  }
  for (__typeof(n) i = 0; i < (n); ++i) {
    long long a, b;
    cin >> a >> b;
    --a;
    --b;
    ++v[a].v;
    ++v[b].v;
    ++ori[a].v;
    ++ori[b].v;
    if (b < a) swap(a, b);
    ++m[a * n + b];
  }
  sort(v.begin(), v.end(),
       [](const Node& a, const Node& b) { return a.v < b.v; });
  long long options = 0;
  for (__typeof(n) fixed = 0; fixed < (n); ++fixed) {
    long long x = v[fixed].v;
    long long missingPart = max(0ll, p - x);
    vector<Node>::iterator it =
        lower_bound(v.begin(), v.end(), Node(-1, missingPart),
                    [](const Node& a, const Node& b) { return a.v < b.v; });
    if (it != v.end()) {
      long long attends;
      if (x >= missingPart)
        attends = static_cast<long long>(v.end() - it - 1);
      else
        attends = static_cast<long long>(v.end() - it);
      options += attends;
    }
  }
  options /= 2;
  for (__typeof((m).begin()) it = (m).begin(); it != (m).end(); ++it) {
    long long i = (it->first) / n;
    long long j = (it->first) % n;
    if (ori[i].v + ori[j].v - it->second < p && ori[i].v + ori[j].v >= p) {
      --options;
    }
  }
  cout << options << endl;
  return 0;
}
