#include <bits/stdc++.h>

using namespace std;

//basic input and data type
#define ll long long  
#define loop(a,b) for(ll int i=a;i<b;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)

//debugging 
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl

//vector functions
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<int, int>pii;
typedef pair<ll, ll>pl;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<pii>vpii;
typedef vector<pl>vpl;
typedef vector<vi>vvi;
typedef vector<vl>vvl;
// solution

void solve()
{
    string s;
    cin>>s;
    ll int cnt=0;
    ll int i;
    for(i=0;i<s.size();i++)
    {
        if(i+3<s.size()&&s[i]=='Z'&&s[i+1]=='O'&&s[i+2]=='N'&&s[i+3]=='e')
        {
            cnt++;
            i=i+3;
        }
    }
    cout<<cnt<<endl;
}

//main function
int main()
{
    ll int t=1;
    //sl(t);
    while(t--)
    {
        solve();
    }
 
   return(0);
}
#include<bits/stdc++.h>
using namespace std;
int const maxn=2e5+10;
int noded=0,tot,cou,son[maxn],head[maxn],n,m,deep[maxn],fa[maxn],ans[maxn];
struct edge{
    int v,nxt;
}e[maxn<<1];
void build(int x,int y){
    e[++tot].v=y;
    e[tot].nxt=head[x];
    head[x]=tot;
}
void getans(int x){
	ans[x]=++cou;
	for(int i=head[x];i;i=e[i].nxt){
        int v=e[i].v;
        if(v==fa[x]||v==son[x])continue;
        getans(v);
        ++cou;
    }
    if(son[x])getans(son[x]);
}
void dfs(int x,int f,int d){
	deep[x]=d;
	fa[x]=f;
	if(deep[noded]<=d){
		noded=x;
	}
	for(int i=head[x];i;i=e[i].nxt){
        int v=e[i].v;
        if(v==f)continue;
        dfs(v,x,d+1);
    }
}
int main(){
    scanf("%d",&n);
    tot=0,cou=0;
    int a,b;
    for(int i=1;i<n;i++){
        scanf("%d%d",&a,&b);
        build(a,b);
        build(b,a);
    }
    dfs(1,0,0);
    int s=noded;
    dfs(s,0,0);
    // cout<<s<<' '<<noded<<endl;
    for(int i=noded;i;i=fa[i]){
    	son[fa[i]]=i;
    }
    getans(s);
    for(int i=1;i<n;i++)printf("%d ",ans[i]);
    printf("%d\n",ans[n]);
    return 0;
}
/*
10
1 2
2 3
3 5
2 4
1 6
1 7
7 8
8 9
7 10
*/