#include <bits/stdc++.h>
using namespace std;
vector<int> g[300009];
int all = 0;
bool used[300009];
int cntSorted[300009];
int cnt[300009];
int pc[300009];
int main() {
  int n, p;
  cin >> n >> p;
  all = n;
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x, --y;
    cnt[x]++;
    cnt[y]++;
    cntSorted[x]++;
    cntSorted[y]++;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  sort(cntSorted, cntSorted + n);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    int ps = lower_bound(cntSorted, cntSorted + n, p - cnt[i]) - cntSorted;
    if (p - cnt[i] <= cnt[i]) ps++;
    ans += n - ps;
    for (int j = 0; j < (int)g[i].size(); ++j) {
      int to = g[i][j];
      if (cnt[to] + cnt[i] - pc[to] == p) {
        ans--;
      }
      pc[to]++;
    }
    for (int j = 0; j < (int)g[i].size(); ++j) {
      pc[g[i][j]] = 0;
    }
  }
  cout << ans / 2;
  return 0;
}
