#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, p;
int deg[N];
vector<int> g[N];
map<int, int> cnt[N];
int suf[N];
int main() {
  scanf("%d %d", &n, &p);
  for (int i = 1; i <= n; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    deg[u]++, deg[v]++;
    cnt[u][v]++, cnt[v][u]++;
  }
  for (int i = 1; i <= n; ++i) suf[deg[i]]++;
  for (int i = n - 1; i >= 0; --i) suf[i] += suf[i + 1];
  long long res = 0;
  for (int i = 1; i <= n; ++i) {
    res += suf[max(0, p - deg[i])];
    for (auto it : cnt[i]) {
      if (deg[it.first] >= max(0, p - deg[i]) &&
          deg[i] + deg[it.first] - it.second < p)
        res--;
    }
    if (deg[i] + deg[i] >= p) res--;
  }
  res /= 2;
  cout << res << '\n';
}
