#include <bits/stdc++.h>
using namespace std;
int row[] = {-1, 0, 1, 0};
int col[] = {0, 1, 0, -1};
int mod = 1e9 + 7;
int mod1 = 998244353;
const long long int ninf = -1 * 1e18;
const long long int pinf = 1e18;
int main() {
  int n, p;
  cin >> n >> p;
  vector<int> freq(n, 0);
  int a, b;
  map<pair<int, int>, int> mp;
  long long int ans = 0ll;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--;
    b--;
    mp[make_pair(a, b)]++;
    freq[a]++;
    freq[b]++;
  }
  for (auto x : mp) {
    int tem = freq[x.first.first] + freq[x.first.second];
    if (tem >= p && tem - x.second < p) ans -= 1;
  }
  sort(freq.begin(), freq.end());
  for (int i = 0; i < n - 1; i++) {
    int pos = lower_bound(freq.begin() + i + 1, freq.end(), p - freq[i]) -
              freq.begin();
    int len = n - max(i + 1, pos);
    ans += len;
  }
  cout << ans << "\n";
  return 0;
}
