#include <bits/stdc++.h>
using namespace std;
template <class T>
T Abs(T x) {
  return x < 0 ? -x : x;
}
int N, M;
int cnt[300001];
int main() {
  while (cin >> N >> M) {
    memset(cnt, 0, sizeof cnt);
    map<pair<int, int>, int> paircnt;
    vector<int> vetex;
    for (int i = (int)0, _m = (int)N; i < _m; ++i) {
      int x, y;
      cin >> x >> y;
      cnt[x]++;
      cnt[y]++;
      if (x > y) swap(x, y);
      paircnt[make_pair(x, y)]++;
    }
    vector<int> sortedcnt(cnt + 1, cnt + N + 1);
    sort(sortedcnt.begin(), sortedcnt.end());
    long long ans = 0;
    for (int i = (int)0, _m = (int)(int)sortedcnt.size(); i < _m; ++i) {
      int x = M - sortedcnt[i];
      ans +=
          distance(lower_bound(sortedcnt.begin() + i + 1, sortedcnt.end(), x),
                   sortedcnt.end());
    }
    for (auto it : paircnt) {
      int x = it.first.first;
      int y = it.first.second;
      if (cnt[x] + cnt[y] >= M) {
        if (cnt[x] + cnt[y] - it.second < M) ans--;
      }
    }
    cout << ans << endl;
  }
}
