#include <bits/stdc++.h>
using namespace ::std;
const long long maxn = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 500;
vector<long long> ger[maxn];
vector<long long> vec;
long long cnt[maxn];
int main() {
  long long n, p;
  cin >> n >> p;
  for (long long i = 0; i < n; i++) {
    long long v, u;
    cin >> v >> u;
    ger[u].push_back(v);
    ger[v].push_back(u);
  }
  for (long long i = 1; i <= n; i++) {
    vec.push_back(ger[i].size());
  }
  sort(vec.begin(), vec.end());
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < ger[i].size(); j++) {
      cnt[ger[i][j]]++;
    }
    for (long long j = 0; j < ger[i].size(); j++) {
      long long v = ger[i][j];
      if (cnt[v] != 0 && ger[v].size() + ger[i].size() >= p) {
        if (ger[i].size() + ger[v].size() - cnt[v] < p) {
          ans--;
        }
      }
      cnt[v] = 0;
    }
    ans += n - ((lower_bound(vec.begin(), vec.end(), p - ger[i].size()) -
                 vec.begin()));
    if (ger[i].size() * 2 >= p) {
      ans--;
    }
  }
  cout << ans / 2;
}
