#include <bits/stdc++.h>
using namespace std;
struct HASH {
  size_t operator()(const pair<int, int> &x) const {
    return hash<long long>()(((long long)x.first) ^
                             (((long long)x.second) << 32));
  }
};
int d[300000];
bool comp(int a, int b) { return d[a] < d[b]; }
int main() {
  ios::sync_with_stdio(0);
  int n, p;
  cin >> n >> p;
  vector<int> graph[n];
  unordered_map<pair<int, int>, int, HASH> m;
  m.reserve(65536);
  m.max_load_factor(0.25);
  memset(d, 0, sizeof d);
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    if (x > y) swap(x, y);
    graph[x].push_back(y);
    graph[y].push_back(x);
    m[make_pair(x, y)]++;
    d[x]++;
    d[y]++;
  }
  pair<int, int> v[n];
  for (int i = 0; i < n; ++i) {
    v[i].first = d[i];
    v[i].second = i;
  }
  sort(v, v + n);
  long long ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    int u = v[i].second;
    int ux = p - v[i].first;
    int lx = lower_bound(v, v + n, make_pair(ux, -1)) - v;
    ans += n - max(lx, i + 1);
    for (auto &ss : graph[u]) {
      auto mx = make_pair(min(ss, u), max(ss, u));
      int val = m[mx];
      m[mx] = 0;
      if (d[ss] + d[u] >= p && d[ss] + d[u] - val < p) --ans;
    }
  }
  cout << ans << '\n';
}
