#include <bits/stdc++.h>
const int MAX = 3e5 + 11;
using namespace std;
vector<int> adj[MAX];
set<int> jda[MAX];
int main() {
  int N, P;
  scanf("%d%d", &N, &P);
  for (int i = 0; i < (N); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  vector<pair<int, int> > deg;
  for (int i = (1); i <= (N); ++i) deg.push_back(make_pair(adj[i].size(), i));
  sort(deg.begin(), deg.end());
  int64_t res = 0;
  for (int i = 0; i < (int((deg).size())); ++i) {
    int a = i + 1, b = N - 1;
    while (a < b) {
      int m = (a + b) / 2;
      if (deg[m].first + deg[i].first < P) {
        a = m + 1;
      } else {
        b = m;
      }
    }
    if (deg[a].first + deg[i].first >= P) {
      res += (N - a);
    }
  }
  for (int i = 0; i < (N); ++i) {
    for (int j = 0; j < (int((adj[i]).size())); ++j) {
      jda[i].insert(adj[i][j]);
    }
  }
  set<pair<int, int> > was;
  for (int i = 0; i < (N); ++i) {
    for (auto j = jda[i].begin(); j != jda[i].end(); ++j) {
      int val = adj[i].size() + adj[*j].size();
      if (val >= P) {
        int w = *j, c = 0;
        for (int k = 0; k < (int((adj[w]).size())); ++k) {
          if (adj[w][k] == i) {
            c++;
          }
        }
        pair<int, int> p = make_pair(min(i, w), max(i, w));
        if (val - c < P && was.find(p) == was.end()) {
          res--;
          was.insert(p);
        }
      }
    }
  }
  cout << res;
  return 0;
}
