#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300005;
map<pair<int, int>, int> M;
map<pair<int, int>, int>::iterator it;
int C[MAXN];
int C2[MAXN];
struct node {
  int idx, cnt;
};
node P[MAXN];
bool cmp(const node &a, const node &b) { return a.cnt < b.cnt; }
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);
    if (x > y) swap(x, y);
    C[x]++;
    C[y]++;
    M[make_pair(x, y)]++;
  }
  for (int i = 1; i < n + 1; i++) C2[i] = C[i];
  sort(C + 1, C + n + 1);
  long long int ans = 0;
  int j = n;
  for (int i = 1; i < n + 1; i++) {
    while (j > 0 && C[i] + C[j] >= p) j--;
    ans += n - max(j, i);
  }
  for (it = M.begin(); it != M.end(); it++) {
    int x = it->first.first;
    int y = it->first.second;
    if (C2[x] + C2[y] >= p && C2[x] + C2[y] - it->second < p) ans--;
  }
  cout << ans << endl;
  return 0;
}
