#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
using namespace std;
void solve() {
  int n, p;
  cin >> n >> p;
  map<pair<int, int>, int> mp;
  vector<int> num(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--;
    b--;
    num[a]++;
    num[b]++;
    mp[make_pair(a, b)]++;
  }
  long long ans = 0;
  for (const auto &it : mp) {
    int a = it.first.first;
    int b = it.first.second;
    int cnt = it.second;
    if (num[a] + num[b] >= p && num[a] + num[b] - cnt < p) ans--;
  }
  sort(num.begin(), num.end());
  for (int i = 0; i < n; i++) {
    int pos = lower_bound(num.begin(), num.end(), p - num[i]) - num.begin();
    ans += n - max(pos, i + 1);
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
