#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int MAXN = 3e5 + 5;
const long long mod = 1e9 + 7;
int ps[MAXN], c[MAXN], n, p;
vector<int> Mat[MAXN];
long long res;
int main() {
  cin >> n >> p;
  ps[0] = n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    Mat[a].push_back(b);
    Mat[b].push_back(a);
    c[a]++;
    ps[c[a]]++;
    c[b]++;
    ps[c[b]]++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < Mat[i].size(); j++) ps[c[Mat[i][j]]]--, c[Mat[i][j]]--;
    if (c[i] + c[i] >= p) res--;
    res += ps[max(0, p - c[i])];
    for (int j = 0; j < Mat[i].size(); j++) c[Mat[i][j]]++, ps[c[Mat[i][j]]]++;
  }
  res /= 2;
  cout << res;
  return 0;
}
