#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3 * 1000 * 100 + 9;
map<pair<int, int>, int> cnt;
set<int> neighbors[MAXN];
int n, p;
int deg[MAXN];
int deg_sort[MAXN];
int bin_search(int val) {
  int L = 0, R = n - 1, M;
  while (R - L > 1) {
    M = (L + R) >> 1;
    if (deg_sort[M] >= val)
      R = M;
    else
      L = M;
  }
  if (deg_sort[L] >= val)
    return L;
  else if (deg_sort[R] >= val)
    return R;
  else
    return n;
}
int solve_neighbors_plus(int i) {
  int result = 0;
  for (set<int>::iterator it = neighbors[i].begin(); it != neighbors[i].end();
       it++) {
    int neig = *it;
    int first = deg[i] + deg[neig];
    if (first >= p) {
      result++;
      if (first - cnt[make_pair(i, neig)] - cnt[make_pair(neig, i)] >= p)
        result--;
    }
  }
  return result;
}
int solve_all(int i) {
  int temp = p - deg[i];
  int res = bin_search(temp);
  return n - res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> p;
  for (int i = 0; i < n; i++) {
    deg[i] = 0;
  }
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    x--;
    y--;
    cnt[make_pair(x, y)]++;
    neighbors[x].insert(y);
    neighbors[y].insert(x);
    deg[x]++;
    deg[y]++;
  }
  memcpy(deg_sort, deg, n * sizeof(int));
  sort(deg_sort, deg_sort + n);
  long long result = 0;
  for (int i = 0; i < n; i++) {
    result -= solve_neighbors_plus(i);
    result += solve_all(i);
    if (2 * deg[i] >= p) result--;
  }
  result /= 2;
  cout << result;
  return 0;
}
