#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300 * 1000 + 10;
int deg[MAXN], t[MAXN];
pair<int, int> e[MAXN];
map<pair<int, int>, int> cnt;
int main() {
  ios::sync_with_stdio(false);
  int n, p;
  cin >> n >> p;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    deg[x]++, deg[y]++;
    t[x]++, t[y]++;
    cnt[make_pair(x, y)]++;
    cnt[make_pair(y, x)]++;
    e[i] = make_pair(x, y);
  }
  sort(deg, deg + n);
  long long ans = 0;
  for (int i = 0, j = n - 1; i < n; i++) {
    while (j > i && deg[i] + deg[j] >= p) j--;
    ans += n - 1 - max(i, j);
  }
  for (int i = 0; i < n; i++) {
    int x = e[i].first, y = e[i].second;
    if (t[x] + t[y] >= p) {
      if (t[x] + t[y] - cnt[make_pair(x, y)] < p) {
        ans--;
        cnt[make_pair(x, y)] = cnt[make_pair(y, x)] = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
