#include <bits/stdc++.h>
using namespace std;
const long long int INF = (long long int)1e9 + 10;
const long long int INFLL = (long long int)1e18 + 10;
const long double EPS = 1e-12;
const long long int MOD = 1e9 + 7;
template <class T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <class T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
template <class T>
inline T sq(T a) {
  return a * a;
}
long long int in() {
  long long int x;
  scanf("%lld", &x);
  return x;
}
char yuyushiki[1000010];
string stin() {
  scanf("%s", yuyushiki);
  return yuyushiki;
}
int n, p;
int s[300010];
map<int, int> ma;
vector<int> G[300010];
int deg[300010];
int main() {
  n = in();
  p = in();
  for (long long int i = (0); i < (long long int)(n); i++) {
    int a = in() - 1;
    int b = in() - 1;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    deg[a]++;
    deg[b]++;
  }
  for (long long int i = (0); i < (long long int)(n); i++) {
    s[deg[i] + 1]++;
  }
  for (long long int i = (0); i < (long long int)(n); i++) {
    s[i + 1] += s[i];
  }
  long long int ans = 0;
  for (long long int i = (0); i < (long long int)(n); i++) {
    ans += n - s[max(0, p - deg[i])];
    if (deg[i] >= max(0, p - deg[i])) {
      ans--;
    }
    ma.clear();
    for (auto &w : G[i]) {
      if (ma.find(w) == ma.end()) {
        ma[w] = 1;
      } else {
        ma[w] = ma[w] + 1;
      }
    }
    for (auto &w : ma) {
      if (deg[w.first] >= max(0, p - deg[i]) &&
          deg[w.first] - w.second < max(0, p - deg[i])) {
        ans--;
      }
    }
  }
  cout << ans / 2 << endl;
  return 0;
}
