#include <bits/stdc++.h>
long long MOD = 1000000007;
long long inf = 1e18;
using namespace std;
vector<long long> S;
long long p[300001];
vector<long long> Children[300001];
int main() {
  ios::sync_with_stdio(0);
  long long i, n, x, y, w, q, a, b, e, j;
  long long ans = 0;
  cin >> n >> w;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    x--;
    y--;
    p[x]++;
    p[y]++;
    Children[x].push_back(y);
    Children[y].push_back(x);
  }
  for (i = 0; i < n; i++) {
    S.push_back(p[i]);
  }
  sort(S.begin(), S.end());
  for (i = 0; i < n; i++) {
    q = p[i];
    a = -1;
    b = S.size();
    while (b - a > 1) {
      e = (b + a) / 2;
      if (S[e] + q >= w) {
        b = e;
      } else {
        a = e;
      }
    }
    ans += S.size() - b;
    if (2 * p[i] >= w) ans -= 1;
    for (j = 0; j < Children[i].size(); j++) {
      p[Children[i][j]] -= 1;
      if (q + p[Children[i][j]] == w - 1) {
        ans -= 1;
      }
    }
    for (j = 0; j < Children[i].size(); j++) {
      p[Children[i][j]] += 1;
    }
  }
  cout << ans / 2;
  return 0;
}
