#include <bits/stdc++.h>
using namespace std;
const int MaxN = 300005;
map<pair<int, int>, int> m;
int num[MaxN];
int a[MaxN], sum[MaxN];
int main() {
  int n, p;
  scanf("%d%d", &n, &p);
  m.clear();
  memset(num, 0, sizeof(num));
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    num[x]++;
    num[y]++;
    if (x > y) swap(x, y);
    m[make_pair(x, y)]++;
  }
  for (int i = 1; i <= n; i++) a[num[i]]++;
  memset(sum, 0, sizeof(sum));
  for (int i = n; i >= 0; i--) {
    sum[i] = sum[i + 1] + a[i];
  }
  long long sol = 0;
  for (int i = 1; i <= n; i++) sol += sum[max(0, p - num[i])];
  for (int i = 1; i <= n; i++)
    if (num[i] + num[i] >= p) sol--;
  sol /= 2;
  for (__typeof((m).begin()) pointer = (m).begin(); pointer != (m).end();
       pointer++) {
    int i = (pointer->first).first;
    int j = (pointer->first).second;
    if (num[i] + num[j] >= p) sol--;
    if (num[i] + num[j] - (pointer->second) >= p) sol++;
  }
  printf("%I64d\n", sol);
  return 0;
}
