#include <bits/stdc++.h>   using namespace std;   map<int, int> glosy;   map<pair<int, int>, int> parki;   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = (0); i < (n); i++) {       int a, b;       scanf( %d%d , &a, &b);       if (a > b) swap(a, b);       if (glosy.find(a) != glosy.end())         glosy[a]++;       else         glosy.insert(make_pair(a, 1));       if (glosy.find(b) != glosy.end())         glosy[b]++;       else         glosy.insert(make_pair(b, 1));       if (parki.find(make_pair(a, b)) != parki.end())         parki[make_pair(a, b)]++;       else         parki.insert(make_pair(make_pair(a, b), 1));     }     if (m == 0) {       cout << (n * 1LL * (n - 1LL)) / 2LL << endl;       return 0;     }     long long int res = 0LL;     vector<int> v;     for (map<int, int>::iterator it = glosy.begin(); it != glosy.end(); it++)       v.push_back(it->second);     int jeszcze = n - v.size();     sort(v.begin(), v.end());     int k = v.size();     for (int i = (0); i < (k); i++) {       vector<int>::iterator it2 = lower_bound(v.begin(), v.end(), m - v[i]);       int ile = (v.end() - it2);       if (v[i] + v[i] >= m) ile--;       if (v[i] >= m) ile += 2 * jeszcze;       res += ile * 1LL;     }     res = res / 2;     for (map<pair<int, int>, int>::iterator it = parki.begin(); it != parki.end();          it++) {       pair<int, int> para = it->first;       int a = para.first;       int b = para.second;       int x = glosy[a] + glosy[b] - it->second;       if (x < m && ((glosy[a] + glosy[b]) >= m)) res--;     }     cout << res << endl;     return 0;   }   