#include <bits/stdc++.h>
using namespace std;
const int N = 300100;
int n, p, A, B, a[N], b[N];
pair<int, int> x[N];
long long ans;
int main(int argc, char **argv) {
  scanf("%d%d", &n, &p);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &x[i].first, &x[i].second);
    if (x[i].first > x[i].second) swap(x[i].first, x[i].second);
    ++a[x[i].first], ++a[x[i].second];
  }
  for (int i = 0; i <= n; ++i) b[i] = a[i];
  sort(b + 1, b + 1 + n);
  for (int i = n, j = 1; i > j; --i) {
    while (b[j] + b[i] < p && j < i) ++j;
    ans += i - j;
  }
  sort(x, x + n);
  for (int i = 0, j; i < n; i = j) {
    j = i + 1;
    while (j < n && x[j] == x[i]) ++j;
    A = x[i].first, B = x[i].second;
    if (a[A] + a[B] >= p && a[A] + a[B] - (j - i) < p) --ans;
  }
  cout << ans << endl;
  return 0;
}
