/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	
	 public static int n = 7;

	public static int[] parent = {0, 1, 2, 3, 4, 5, 6};
	public static int[] rank = {0, 0, 0, 0, 0, 0, 0};

	public static int find(int node){
		if(parent[node] == node){
			return node;
		}else{
			int up = find(parent[node]);
			parent[node] = up;
			return parent[node];
		}
	}
	
	public static void union(int a, int b){
		
		int root1 = find(a);
		int root2 = find(b);
		
		if(root1 == root2){
			return;
		}else{
			if(rank[root1] < rank[root2]){
				parent[root1] = parent[root2];
			}else if(rank[root1] > rank[root2]){
				parent[root2] = parent[root2];
			}else{
				parent[root1] = root2;
				int ranku = rank[root1];
				rank[root1] = ranku + 1;
			}
		}
	}
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		
		union(1, 2);
		union(2, 3);
		union(5, 4);
		
		System.out.print(find(4));
		
	 
	}
}