#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10;
map<pair<int, int>, int> m;
vector<int> G[3 * MAXN], v;
int te[3 * MAXN];
long long ans = 0;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, p;
  cin >> n >> p;
  for (int i = 1; i <= n; i++) {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    te[a]++;
    te[b]++;
    m[pair<int, int>(a, b)]++;
    if (m[pair<int, int>(a, b)] == 1) {
      G[a].push_back(b);
      G[b].push_back(a);
    }
  }
  if (p == 0) {
    cout << n * (n - 1) / 2;
    return 0;
  }
  for (int i = 1; i <= n; i++) v.push_back(te[i]);
  sort(v.begin(), v.end());
  for (int i = 1; i <= n; i++) {
    int q = lower_bound(v.begin(), v.end(), p - te[i]) - v.begin();
    ans += n - q;
    if (te[i] >= p - te[i]) ans--;
    for (int j = 0; j < G[i].size(); j++)
      if (te[i] + te[G[i][j]] >= p &&
          (te[i] + te[G[i][j]] -
           m[pair<int, int>(min(i, G[i][j]), max(i, G[i][j]))]) < p)
        ans--;
  }
  cout << ans / 2;
}
