#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> store;
const int MAX = 300008;
int inp[MAX];
int freq[MAX];
int main() {
  int n, p, a, b;
  cin >> n >> p;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    a--, b--;
    if (a < b) swap(a, b);
    store[pair<int, int>(a, b)]++;
    inp[a]++, inp[b]++;
  }
  for (int i = 0; i < n; i++) freq[i] = inp[i];
  sort(freq, freq + n);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int lb = lower_bound(freq, freq + n, p - freq[i]) - freq;
    ans += n - max(lb, i + 1);
  }
  for (map<pair<int, int>, int>::iterator it = store.begin(); it != store.end();
       it++) {
    a = it->first.first, b = it->first.second, n = it->second;
    if (inp[a] + inp[b] >= p)
      if (inp[a] + inp[b] - n < p) ans--;
  }
  cout << ans << endl;
  return 0;
}
