#include <bits/stdc++.h>
using namespace std;
int x[300005], y[300005];
int C[300005];
int pos[300005];
map<pair<int, int>, int> Map;
vector<vector<int> > adj;
int main() {
  int N, P;
  scanf("%d%d", &N, &P);
  vector<int> temp;
  for (int i = 0; i < N; i++) {
    C[i] = 0;
    adj.push_back(temp);
  }
  for (int i = 0; i < N; i++) {
    scanf("%d%d", &x[i], &y[i]);
    x[i]--, y[i]--;
    C[x[i]]++, C[y[i]]++;
  }
  long long ans1 = 0;
  for (int i = 0; i < N; i++) {
    pair<int, int> v1 = make_pair(min(x[i], y[i]), max(x[i], y[i]));
    if (Map.count(v1) > 0)
      Map[v1]++;
    else
      Map[v1] = 1;
  }
  map<pair<int, int>, int>::iterator it;
  for (it = Map.begin(); it != Map.end(); it++) {
    int v1 = (*it).first.first, v2 = (*it).first.second, c1 = (*it).second;
    adj[v1].push_back(v2);
    adj[v2].push_back(v1);
    int c = C[v1] + C[v2] - c1;
    if (c >= P) {
      ans1++;
    }
  }
  long long ans2 = 0;
  vector<pair<int, int> > A;
  for (int i = 0; i < N; i++) A.push_back(make_pair(C[i], i));
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++) pos[A[i].second] = i;
  vector<int> B;
  for (int i = 0; i < N; i++) B.push_back(A[i].first);
  for (int i = 0; i < N; i++) {
    int u = A[i].second, c = A[i].first;
    int v = (P - c) - 1;
    vector<int>::iterator up;
    up = upper_bound(B.begin(), B.end(), v);
    int ind = up - B.begin();
    if (ind <= i) ind = i + 1;
    if (ind == N) continue;
    long long temp2 = (N - 1 - ind + 1);
    for (int j = 0; j < adj[u].size(); j++) {
      if (pos[adj[u][j]] >= ind) {
        temp2--;
      }
    }
    ans2 += temp2;
  }
  long long ans = ans1 + ans2;
  cout << ans << endl;
  return 0;
}
