#include <bits/stdc++.h>
using namespace std;
const long long o = 3e5 + 1;
long long n, m, ans, a[o], b[o];
map<pair<long long, long long>, long long> s;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 1, x, y; i <= n; i++) {
    cin >> x >> y, x--, y--;
    a[x]++, a[y]++;
    if (x > y) swap(x, y);
    s[make_pair(x, y)]++;
  }
  for (long long i = 0; i < n; i++) b[i] = a[i];
  sort(a, a + n);
  for (long long i = 0, r = n - 1; i < n; i++) {
    while (r >= 0 && a[i] + a[r] >= m) r--;
    ans += min(n - r - 1, n - i - 1);
  }
  map<pair<long long, long long>, long long>::iterator it;
  for (it = s.begin(); it != s.end(); it++) {
    pair<long long, long long> x = it->first;
    if (b[x.first] + b[x.second] >= m &&
        b[x.first] + b[x.second] - it->second < m)
      ans--;
  }
  cout << ans;
  return 0;
}
