#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
} a[300000 + 10];
map<int, int> vis;
int n, p, zhichi[300000 + 10], temp[300000 + 10];
int main() {
  long long ans = 0;
  memset(zhichi, 0, sizeof(zhichi));
  memset(temp, 0, sizeof(temp));
  scanf("%d%d", &n, &p);
  for (int i = 0; i <= n - 1; i++) {
    scanf("%d%d", &a[i].x, &a[i].y);
    zhichi[a[i].x]++;
    zhichi[a[i].y]++;
    temp[a[i].x]++;
    temp[a[i].y]++;
    if (a[i].x > a[i].y) swap(a[i].x, a[i].y);
    vis[a[i].x] = 1;
    vis[a[i].y] = 1;
  }
  sort(temp + 1, temp + n + 1);
  for (int i = 1; i <= n; i++) {
    int tt = lower_bound(temp + i + 1, temp + n + 1, p - temp[i]) - temp;
    ans += n - tt + 1;
  }
  map<pair<int, int>, int> mp, flag;
  for (int i = 0; i <= n - 1; i++) {
    mp[make_pair(a[i].x, a[i].y)]++;
  }
  for (int i = 0; i <= n - 1; i++) {
    int cnt = mp[make_pair(a[i].x, a[i].y)];
    if (zhichi[a[i].x] + zhichi[a[i].y] >= p &&
        zhichi[a[i].x] + zhichi[a[i].y] - cnt < p &&
        flag.count(make_pair(a[i].x, a[i].y)) == 0) {
      flag[make_pair(a[i].x, a[i].y)] = 1;
      ans--;
    }
  }
  printf("%lld\n", ans);
}
