#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())

const unsigned int BIT_FLAG_0 = (1 << 0);  // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1);  // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2);  // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3);  // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4);  // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5);  // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6);  // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7);  // 0000 0000 1000 0000

const double PI = 3.14159265358979323846;

const int dy[4] = {0, 1, 0, -1};
const int dx[4] = {1, 0, -1, 0};

#define H_MAX 500
#define W_MAX 500
#define INF 1e9 + 7
const long long MOD = 998244353;

bool IsPrime(int num) {
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;  // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    ll N, cnt = 0;
    unordered_set<ll> us;
    cin >> N;

    for (ll i = 2; i * i <= N; i++) {
        ll tmp = i * i;
        while (tmp <= N) {
            us.insert(tmp);
            tmp *= i;
        }
    }
    cout << N - us.size() << endl;
}
#include <bits/stdc++.h>
 
#define LL long long
#define ull unsigned long long
#define F(i, j, k) for (int i = j; i <= k; ++i)
#define DF(i, j, k) for (int i = j; i >= k; --i)
 
using namespace std;
 
template <typename T> inline void read(T &n) {
	T w = 1;
	n = 0;
	char ch = getchar();
	while (!isdigit(ch) && ch != EOF) {
		if (ch == '-') w = -1;
		ch = getchar();
	}
	while (isdigit(ch) && ch != EOF) {
		n = (n << 3) + (n << 1) + (ch & 15);
		ch = getchar();
	}
	n *= w;
}
 
template <typename T> inline void write(T x) {
	T l = 0;
	ull y = 0;
	if (!x) { putchar(48); return; }
	if (x < 0) { x = -x; putchar('-'); }
	while (x) { y = y * 10 + x % 10; x /= 10; ++l; }
	while (l) { putchar(y % 10 + 48); y /= 10; --l; }
}
 
template <typename T> inline void writes(T x) {
	write(x);
	putchar(' ');
}
 
template <typename T> inline void writeln(T x) {
	write(x);
	puts("");
}
 
template <typename T> inline void checkmax(T &a, T b) { a = a > b ? a : b; }
 
template <typename T> inline void checkmin(T &a, T b) { a = a < b ? a : b; }
 
const int N = 2e5 + 100;
 
int cnt, head[N], to[N << 1], nxt[N << 1];
 
inline void addedge(int x, int y) {
	nxt[++cnt] = head[x];
	to[cnt] = y;
	head[x] = cnt;
}
 
int tp[N], rt, depth[N], mx = 0;
 
inline void dfs(int x, int fa) {
	for (int i = head[x]; i; i = nxt[i]) {
		if (to[i] == fa) continue;
		depth[to[i]] = depth[x] + 1;
		if (depth[to[i]] >= mx) { rt = to[i]; mx = depth[to[i]]; }
		dfs(to[i], x);
	}
}
 
int tot, ans[N];
 
inline void dfs2(int x, int fa) {
	ans[x] = ++tot;
	for (int i = head[x]; i; i = nxt[i]) {
		if (to[i] == fa || tp[to[i]]) continue;
		dfs2(to[i], x);
	}
	for (int i = head[x]; i; i = nxt[i]) {
		if (to[i] == fa || !tp[to[i]]) continue;
		dfs2(to[i], x);
	}
	++tot;
}
 
inline void dfs3(int x, int fa) {
	for (int i = head[x]; i; i = nxt[i]) {
		if (to[i] == fa) continue;
		dfs3(to[i], x);
		if (tp[to[i]]) tp[x] = 1;
	}
}
 
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n;
	read(n);
	F(i, 1, n - 1) {
		int x, y;
		read(x); read(y);
		addedge(x, y);
		addedge(y, x);
	}
	dfs(1, 0);
	depth[rt] = 0;
	tp[rt] = 1;
	dfs(rt, 0);
	dfs3(rt, 0);
	dfs2(rt, 0);
	F(i, 1, n) writes(ans[i]);
	return 0;
}