#include <bits/stdc++.h>
using namespace std;
int d[300001];
int e[300001];
map<pair<int, int>, int> pa;
int main() {
  int n, m;
  int a, b;
  long long sol = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    a--;
    b--;
    d[a]++;
    d[b]++;
    if (a > b) swap(a, b);
    pa[make_pair(a, b)]++;
  }
  memcpy(e, d, sizeof(e));
  sort(d, d + n);
  for (int i = 0; i < n; i++) {
    int p = lower_bound(d, d + n, m - d[i]) - d;
    sol += n - p;
    if (d[i] + d[i] >= m) sol--;
  }
  sol /= 2;
  for (map<pair<int, int>, int>::iterator it = pa.begin(); it != pa.end();
       it++) {
    a = it->first.first;
    b = it->first.second;
    if (e[a] + e[b] >= m && e[a] + e[b] - it->second < m) sol--;
  }
  cout << sol << endl;
  return 0;
}
