#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 1;
long long t[N];
void upd(long long p) {
  for (; p > 0; p -= p & -p) t[p]++;
}
long long _get(long long p) {
  long long ans = 0;
  for (; p < N; p += p & -p) ans += t[p];
  return ans;
}
map<pair<long long, long long>, long long> mp;
long long deg[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, p;
  cin >> n >> p;
  for (long long i = 1; i <= n; ++i) {
    long long x, y;
    cin >> x >> y;
    mp[pair<long long, long long>(x, y)]++;
    mp[pair<long long, long long>(y, x)]++;
    deg[x]++;
    deg[y]++;
  }
  for (long long i = 1; i <= n; ++i) upd(deg[i] + 1);
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    ans += _get(max(p - deg[i] + 1, 1ll));
    if (2 * deg[i] >= p) ans--;
  }
  for (auto it : mp) {
    long long u = it.first.first, v = it.first.second;
    if (deg[u] + deg[v] < p) continue;
    if (deg[u] + deg[v] >= p + it.second) continue;
    ans--;
  }
  cout << ans / 2 << endl;
}
