#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-10;
const int MOD = 100000007;
const int MAXN = 310000;
const double PI = acos(-1.0);
struct Node {
  int n, num;
  int operator<(const Node& a) const { return num < a.num; }
} ipt[MAXN];
int cnt[MAXN];
int cmp(Node& a, int b) { return a.num < b; }
int main() {
  int n, k, a, b;
  while (~scanf("%d%d", &n, &k)) {
    memset(cnt, 0, sizeof(cnt));
    map<pair<int, int>, int> mp;
    for (int i = (1); i <= (n); ++i) ipt[i].n = i;
    for (int i = (1); i <= (n); ++i) ipt[i].num = 0;
    for (int i = 0; i < (n); ++i) {
      scanf("%d", &a);
      ipt[a].num++;
      cnt[a]++;
      scanf("%d", &b);
      ipt[b].num++;
      cnt[b]++;
      if (a > b) swap(a, b);
      mp[make_pair(a, b)]++;
    }
    sort(ipt + 1, ipt + n + 1);
    long long ans = 0;
    for (int i = (1); i <= (n); ++i) {
      int ind =
          lower_bound(ipt + i + 1, ipt + n + 1, k - ipt[i].num, cmp) - ipt;
      ans += n - ind + 1;
    }
    for (__typeof((mp).begin()) it = (mp).begin(); it != (mp).end(); it++) {
      a = (it->first).first;
      b = (it->first).second;
      if (cnt[a] + cnt[b] >= k && cnt[a] + cnt[b] - it->second < k) ans--;
    }
    cout << ans << endl;
  }
  return 0;
}
