#include <bits/stdc++.h>
using namespace std;
int arr[300005];
map<pair<int, int>, int> h;
int main(int argc, char const* argv[]) {
  int n, p;
  scanf("%d %d", &n, &p);
  for (int i = 0; i < n; i += 1) {
    int x, y;
    scanf("%d %d", &x, &y);
    arr[x - 1]++;
    arr[y - 1]++;
    if (x > y) swap(x, y);
    h[make_pair(x - 1, y - 1)]++;
  }
  long long ans = 0;
  map<pair<int, int>, int>::iterator it;
  for (it = h.begin(); it != h.end(); ++it) {
    int c = it->second;
    int d1 = it->first.first;
    int d2 = it->first.second;
    int sum = arr[d1] + arr[d2];
    if (sum >= p && sum - c < p) ans -= 2;
  }
  sort(arr, arr + n);
  for (int i = 0; i < n; i += 1) {
    int req = p - arr[i];
    int* pos = lower_bound(arr, arr + n, req);
    if (pos <= arr + i) --ans;
    ans += (arr + n) - pos;
  }
  ans /= 2LL;
  cout << ans << "\n";
  return 0;
}
