#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define pb push_back
using namespace std;using ll = long long;
using vi = vector<ll>;
const int maxn = 1<<18, mod = 998244353;
int tr[2*maxn], n, tin[maxn], tout[maxn], par[maxn], timer = 0;
vi g[maxn];
void upd(int i, int v) {
	for(tr[i += n] = v; i>>=1;) tr[i] = min(tr[i<<1], tr[i<<1|1]);
}
int get(int l, int r) {
	int a = 1<<30;
	for(l += n, r += n+1; l < r; l>>=1, r>>=1) {
		if(l&1) a = min(a, tr[l++]);
		if(r&1) a = min(a, tr[--r]);
	}
	return a;
}
void euler(int v = 1, int p = -1) {
	par[v] = p;
	tin[v] = timer++;
	upd(tin[v], 1<<30);
	for(auto &i : g[v]) {
		if(i == p) continue;
		euler(i, v);
	}
	tout[v] = timer-1;
}
int cur = 0, ans[maxn], used[maxn], cnt = 0;
vi l;
void enq(int v) {
	if(used[v]) return;
	l.pb(v);
	cnt++;
	used[v] = 1;
	upd(tin[v], 1<<30);
	for(auto i : g[v]) {
		if(i == par[v]) continue;
		upd(tin[i], i);
	}
}
void deq(int v) {
	if(!used[v]) return;
	cnt--;
	used[v] = 0;
	upd(tin[v], 1<<30);
	for(auto i : g[v]) {
		if(i == par[v]) continue;
		upd(tin[i], 1<<30);
	}
}
void dfs(int v = 1, int p = -1, int mx = -1) {
	int t, q = l.size();
	enq(v);
	while((t = get(tin[v], tout[v])) < mx) {
		enq(t);
	}
	ans[v] = cnt;
	for(auto i : g[v]) {
		if(i == p) continue;
		dfs(i, v, max(mx, v));
	}
	while(l.size() > q) deq(l.back()), l.pop_back();
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for(int f, t, i = 1; i < n; i++) {
		cin >> f >> t;
		g[f].pb(t);
		g[t].pb(f);
	}
	euler();
	dfs();
	for(int i = 2; i <= n; i++) cout << ans[i]-1 << " ";
}
