#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long s = 0;
  bool f = 0;
  char ch = ' ';
  while (!isdigit(ch)) {
    f |= (ch == '-');
    ch = getchar();
  }
  while (isdigit(ch)) {
    s = (s << 3) + (s << 1) + (ch ^ 48);
    ch = getchar();
  }
  return (f) ? (-s) : (s);
}
inline void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x < 10) {
    putchar(x + '0');
    return;
  }
  write(x / 10);
  putchar((x % 10) + '0');
}
const int N = 300005;
int n, m;
long long ans = 0;
map<pair<int, int>, int> Map;
set<pair<int, int> > MapS;
set<pair<int, int> >::iterator it;
struct node {
  int id, deg;
} a[N];
inline bool cmpdeg(node p, node q) { return p.deg < q.deg; }
inline bool cmpid(node p, node q) { return p.id < q.id; }
int main() {
  int i, j, x, y;
  n = read();
  m = read();
  for (i = 1; i <= n; i++) {
    x = read();
    y = read();
    if (x > y) swap(x, y);
    a[x].deg++;
    a[y].deg++;
    a[i].id = i;
    Map[pair<int, int>(x, y)]++;
    MapS.insert(pair<int, int>(x, y));
  }
  sort(a + 1, a + n + 1, cmpdeg);
  j = 1;
  for (i = n; i >= 1; i--) {
    while (j < i && a[j].deg + a[i].deg < m) j++;
    if (j < i) ans += 1LL * (i - j);
  }
  sort(a + 1, a + n + 1, cmpid);
  for (it = MapS.begin(); it != MapS.end(); it++) {
    x = (*it).first;
    y = (*it).second;
    if (a[x].deg + a[y].deg >= m && a[x].deg + a[y].deg - Map[*it] < m) ans--;
  }
  write(ans), putchar('\n');
  return 0;
}
