#include <bits/stdc++.h>
using namespace std;
int n, m;
int num[300005];
map<pair<int, int>, int> ma;
int main() {
  srand((unsigned int)time(NULL));
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    num[a]++;
    num[b]++;
    if (a > b) swap(a, b);
    ma[make_pair(a, b)]++;
  }
  vector<int> zip;
  for (int i = 1; i <= n; i++) zip.push_back(num[i]);
  sort(zip.begin(), zip.end());
  long long tot = 0;
  for (int i = 1; i <= n; i++) {
    int x = lower_bound(zip.begin(), zip.end(), m - num[i]) - zip.begin();
    tot += zip.size() - x;
  }
  for (int i = 1; i <= n; i++)
    if (num[i] * 2 >= m) tot--;
  tot /= 2;
  for (map<pair<int, int>, int>::iterator it = ma.begin(); it != ma.end();
       it++) {
    pair<int, int> p = it->first;
    int oc = it->second;
    int tot2 = num[p.first] + num[p.second] - oc;
    if (tot2 < m && num[p.first] + num[p.second] >= m) tot--;
  }
  cout << tot << endl;
}
