#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300010;
int N, p, i, j, D[MAXN];
long long ANS = 0;
int Ds[MAXN];
const int FIELD = 2333333;
struct Unordered_Multiset {
  long long Alloc[FIELD];
  int Val[FIELD], Indices[FIELD], Size;
  void Init() {
    Size = 0;
    int i;
    for (i = 0; i <= FIELD - 1; i++) Val[i] = 0;
  }
  void Release() {
    while (Size) Val[Indices[Size--]] = 0;
  }
  void Insert(long long x) {
    int Hv = x % FIELD;
    while ((Val[Hv]) && (Alloc[Hv] != x)) Hv = (Hv * 233 + 23333) % FIELD;
    Alloc[Hv] = x;
    if (Val[Hv] == 0) Indices[++Size] = Hv;
    Val[Hv]++;
  }
};
Unordered_Multiset um;
int main() {
  scanf("%d%d", &N, &p);
  for (i = 1; i <= N; i++) D[i] = 0;
  um.Init();
  for (i = 1; i <= N; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u > v) swap(u, v);
    D[u]++;
    D[v]++;
    um.Insert((((long long)u) << 32) + v);
  }
  long long ANS = 0;
  for (i = 1; i <= N; i++) Ds[i] = D[i];
  sort(Ds + 1, Ds + N + 1);
  for (i = N, j = 1; i > j; i--) {
    while ((j < i) && (Ds[i] + Ds[j] < p)) j++;
    ANS += i - j;
  }
  for (i = 1; i <= um.Size; i++) {
    int u = um.Alloc[um.Indices[i]] >> 32;
    int v = (um.Alloc[um.Indices[i]] << 32) >> 32;
    int w = um.Val[um.Indices[i]];
    if ((D[u] + D[v] >= p) && (D[u] + D[v] - w < p)) ANS--;
  }
  cout << ANS << endl;
}
