#include <bits/stdc++.h>
using namespace std;
const int MAX = 3 * 1e5 + 10;
long long deg[MAX], a[MAX], b[MAX];
map<pair<int, int>, int> cnt;
map<pair<int, int>, bool> vis;
vector<long long> d;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long ans = 0, n, p;
  cin >> n >> p;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] > b[i]) swap(a[i], b[i]);
    deg[a[i]]++;
    deg[b[i]]++;
    cnt[{a[i], b[i]}]++;
  }
  for (int i = 1; i <= n; i++) d.push_back(deg[i]);
  sort(d.begin(), d.end());
  for (int i = 1; i <= n; i++) {
    long long need = p - deg[i];
    long long ind = lower_bound(d.begin(), d.end(), need) - d.begin();
    ans += (n - ind);
    if (deg[i] + deg[i] >= p) ans--;
  }
  for (int i = 0; i < n; i++) {
    if (!vis[{a[i], b[i]}])
      if (deg[a[i]] + deg[b[i]] - cnt[{a[i], b[i]}] < p &&
          deg[a[i]] + deg[b[i]] >= p)
        ans -= 2;
    vis[{a[i], b[i]}] = true;
  }
  cout << ans / 2;
}
