import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		Map<Integer, ArrayList<Integer>> tree = new HashMap<Integer, ArrayList<Integer>>();
 		for(int i = 1;i<=n;i++){
 			tree.put(i, new ArrayList<Integer>());
 		}
 		tree.get(1).add(-1);
 		for(int i = 0;i<n-1;i++){
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		int a = Integer.parseInt(st.nextToken());
	 		tree.get(i+2).add(a);
	 		tree.get(a).add(i+2);
 		}
 		for(int i = 1;i<=n;i++){
 			out.println((tree.get(i).size()-1));
 		}
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	

 import java.util.*; util.* java import java.io.*; io.* java public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		Map<Integer, ArrayList<Integer>> tree = new HashMap<Integer, ArrayList<Integer>>();
 		for(int i = 1;i<=n;i++){
 			tree.put(i, new ArrayList<Integer>());
 		}
 		tree.get(1).add(-1);
 		for(int i = 0;i<n-1;i++){
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		int a = Integer.parseInt(st.nextToken());
	 		tree.get(i+2).add(a);
	 		tree.get(a).add(i+2);
 		}
 		for(int i = 1;i<=n;i++){
 			out.println((tree.get(i).size()-1));
 		}
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
} Main public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		Map<Integer, ArrayList<Integer>> tree = new HashMap<Integer, ArrayList<Integer>>();
 		for(int i = 1;i<=n;i++){
 			tree.put(i, new ArrayList<Integer>());
 		}
 		tree.get(1).add(-1);
 		for(int i = 0;i<n-1;i++){
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		int a = Integer.parseInt(st.nextToken());
	 		tree.get(i+2).add(a);
	 		tree.get(a).add(i+2);
 		}
 		for(int i = 1;i<=n;i++){
 			out.println((tree.get(i).size()-1));
 		}
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	} main {
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		Map<Integer, ArrayList<Integer>> tree = new HashMap<Integer, ArrayList<Integer>>();
 		for(int i = 1;i<=n;i++){
 			tree.put(i, new ArrayList<Integer>());
 		}
 		tree.get(1).add(-1);
 		for(int i = 0;i<n-1;i++){
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		int a = Integer.parseInt(st.nextToken());
	 		tree.get(i+2).add(a);
	 		tree.get(a).add(i+2);
 		}
 		for(int i = 1;i<=n;i++){
 			out.println((tree.get(i).size()-1));
 		}
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	} int num = 998244353; num 998244353 BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); bf new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int n = Integer.parseInt(bf.readLine()); n Integer.parseInt(bf.readLine()) Integer.parseInt Integer bf.readLine() bf.readLine bf StringTokenizer st = new StringTokenizer(bf.readLine()); st new StringTokenizer(bf.readLine()) Map<Integer, ArrayList<Integer>> tree = new HashMap<Integer, ArrayList<Integer>>(); tree new HashMap<Integer, ArrayList<Integer>>() for(int i = 1;i<=n;i++){
 			tree.put(i, new ArrayList<Integer>());
 		} int i = 1; int i = 1; i 1 i<=n i n i++ i++ i {
 			tree.put(i, new ArrayList<Integer>());
 		} {
 			tree.put(i, new ArrayList<Integer>());
 		} tree.put(i, new ArrayList<Integer>()) tree.put tree i new ArrayList<Integer>() tree.get(1).add(-1) tree.get(1).add tree.get(1) tree.get tree 1 -1 1 for(int i = 0;i<n-1;i++){
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		int a = Integer.parseInt(st.nextToken());
	 		tree.get(i+2).add(a);
	 		tree.get(a).add(i+2);
 		} int i = 0; int i = 0; i 0 i<n-1 i n-1 n 1 i++ i++ i {
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		int a = Integer.parseInt(st.nextToken());
	 		tree.get(i+2).add(a);
	 		tree.get(a).add(i+2);
 		} {
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		int a = Integer.parseInt(st.nextToken());
	 		tree.get(i+2).add(a);
	 		tree.get(a).add(i+2);
 		} int a = Integer.parseInt(st.nextToken()); a Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st tree.get(i+2).add(a) tree.get(i+2).add tree.get(i+2) tree.get tree i+2 i 2 a tree.get(a).add(i+2) tree.get(a).add tree.get(a) tree.get tree a i+2 i 2 for(int i = 1;i<=n;i++){
 			out.println((tree.get(i).size()-1));
 		} int i = 1; int i = 1; i 1 i<=n i n i++ i++ i {
 			out.println((tree.get(i).size()-1));
 		} {
 			out.println((tree.get(i).size()-1));
 		} out.println((tree.get(i).size()-1)) out.println out (tree.get(i).size()-1) tree.get(i).size() tree.get(i).size tree.get(i) tree.get tree i 1 out.println() out.println out out.close() out.close out String[] args args public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		Map<Integer, ArrayList<Integer>> tree = new HashMap<Integer, ArrayList<Integer>>();
 		for(int i = 1;i<=n;i++){
 			tree.put(i, new ArrayList<Integer>());
 		}
 		tree.get(1).add(-1);
 		for(int i = 0;i<n-1;i++){
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		int a = Integer.parseInt(st.nextToken());
	 		tree.get(i+2).add(a);
	 		tree.get(a).add(i+2);
 		}
 		for(int i = 1;i<=n;i++){
 			out.println((tree.get(i).size()-1));
 		}
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
} public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		Map<Integer, ArrayList<Integer>> tree = new HashMap<Integer, ArrayList<Integer>>();
 		for(int i = 1;i<=n;i++){
 			tree.put(i, new ArrayList<Integer>());
 		}
 		tree.get(1).add(-1);
 		for(int i = 0;i<n-1;i++){
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		int a = Integer.parseInt(st.nextToken());
	 		tree.get(i+2).add(a);
	 		tree.get(a).add(i+2);
 		}
 		for(int i = 1;i<=n;i++){
 			out.println((tree.get(i).size()-1));
 		}
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
} Main
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		Map<Integer, ArrayList<Integer>> tree = new HashMap<Integer, ArrayList<Integer>>();
 		for(int i = 1;i<=n;i++){
 			tree.put(i, new ArrayList<Integer>());
 		}
 		tree.get(1).add(-1);
 		for(int i = 0;i<n-1;i++){
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		int a = Integer.parseInt(st.nextToken());
	 		tree.get(i+2).add(a);
	 		tree.get(a).add(i+2);
 		}
 		for(int i = 1;i<=n;i++){
 			out.println((tree.get(i).size()-1));
 		}
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	


