#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;
long long n, p;
map<pair<long long, long long>, long long> mp;
unordered_map<long long, long long> deg;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> p;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    mp[{min(a, b), max(a, b)}] += 1;
    deg[a] += 1;
    deg[b] += 1;
  }
  vector<long long> freq;
  for (long long i = 1; i < n + 1; i++) freq.push_back(deg[i]);
  sort(freq.begin(), freq.end());
  for (long long i = 0; i < freq.size() - 1; i++) {
    long long h =
        upper_bound(freq.begin(), freq.end(), p - freq[i] - 1) - freq.begin();
    if (h > i)
      ans += n - h;
    else
      ans += n - i - 1;
  }
  for (auto x : mp) {
    if (deg[x.first.first] + deg[x.first.second] -
                mp[{x.first.first, x.first.second}] <
            p &&
        deg[x.first.first] + deg[x.first.second] >= p)
      ans -= 1;
  }
  cout << ans << '\n';
}
