#include <bits/stdc++.h>
using namespace std;
int n, p, start[390000], fin[390000];
map<pair<int, int>, int> mp;
int main() {
  scanf("%d %d", &n, &p);
  vector<int> cnt(n, 0);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--;
    y--;
    if (x > y) swap(x, y);
    start[i] = x;
    fin[i] = y;
    cnt[x]++;
    cnt[y]++;
    mp[make_pair(x, y)]++;
  }
  vector<int> cnt2(cnt.begin(), cnt.end());
  sort(cnt.begin(), cnt.end());
  long long ans = 0;
  int j = n;
  for (int i = 0; i < n; i++) {
    while (j - 1 >= i && cnt[i] + cnt[j - 1] >= p) j--;
    if (j < i + 1) j = i + 1;
    ans += n - j;
  }
  for (int i = 0; i < n; i++) {
    if (cnt2[start[i]] + cnt2[fin[i]] < p) continue;
    if (cnt2[start[i]] + cnt2[fin[i]] - mp[make_pair(start[i], fin[i])] < p)
      ans--;
    mp[make_pair(start[i], fin[i])] = 0;
  }
  printf("%I64d\n", ans);
  return 0;
}
