#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
long long n, p;
long long deg[N], t1, t2;
long long deg1[N];
long long ans;
long long ct[N];
struct Node {
  long long x;
  long long y;
} edge[N];
int cmp(Node a, Node b) {
  if (a.x < b.x) return true;
  if (a.x == b.x && a.y < b.y) return true;
  return false;
}
int main() {
  while (~scanf("%I64d%I64d", &n, &p)) {
    memset(deg, 0, sizeof(deg));
    memset(deg1, 0, sizeof(deg1));
    memset(ct, 0, sizeof(ct));
    for (int i = 1; i <= n; i++) {
      scanf("%I64d%I64d", &t1, &t2);
      deg[t1]++;
      if (t1 != t2) deg[t2]++;
      deg1[t1]++;
      if (t1 != t2) deg1[t2]++;
      if (t1 > t2) swap(t1, t2);
      edge[i].x = t1;
      edge[i].y = t2;
    }
    sort(deg + 1, deg + n + 1);
    ans = 0;
    for (int i = 1; i <= n; i++) {
      long long temp = lower_bound(deg + i + 1, deg + n + 1, p - deg[i]) - deg;
      if (temp < n + 1) ans += (n - temp + 1);
    }
    sort(edge + 1, edge + n + 1, cmp);
    long long lastx = 0, lasty = 0, tp = 1, pos = 0;
    for (int i = 1; i <= n; i++) {
      if (edge[i].x == lastx && lasty == edge[i].y) {
        tp++;
      } else {
        ct[pos] = tp;
        tp = 1;
        edge[pos].x = lastx;
        edge[pos++].y = lasty;
        lastx = edge[i].x;
        lasty = edge[i].y;
      }
      if (i == n && edge[i].x == lastx && lasty == edge[i].y) {
        ct[pos] = tp;
        tp = 0;
        edge[pos].x = lastx;
        edge[pos++].y = lasty;
        lastx = edge[i].x;
        lasty = edge[i].y;
      }
    }
    for (int i = 1; i < pos; i++) {
      if ((deg1[edge[i].x] + deg1[edge[i].y] >= p &&
           deg1[edge[i].x] + deg1[edge[i].y] - ct[i] < p))
        ans--;
    }
    printf("%I64d\n", ans);
  }
}
