Further research on zombie thought processes yielded interesting results. As we know from the previous problem, the nervous system of a zombie consists of n brains and m brain connectors joining some pairs of brains together. It was observed that the intellectual abilities of a zombie depend mainly on the topology of its nervous system. More precisely, we define the distance between two brains u and v (1 ≤ u, v ≤ n) as the minimum number of brain connectors used when transmitting a thought between these two brains. The brain latency of a zombie is defined to be the maximum distance between any two of its brains. Researchers conjecture that the brain latency is the crucial parameter which determines how smart a given zombie is. Help them test this conjecture by writing a program to compute brain latencies of nervous systems.

In this problem you may assume that any nervous system given in the input is valid, i.e., it satisfies conditions (1) and (2) from the easy version.

Input

The first line of the input contains two space-separated integers n and m (1 ≤ n, m ≤ 100000) denoting the number of brains (which are conveniently numbered from 1 to n) and the number of brain connectors in the nervous system, respectively. In the next m lines, descriptions of brain connectors follow. Every connector is given as a pair of brains a b it connects (1 ≤ a, b ≤ n and a ≠ b).

Output

Print one number – the brain latency.

Examples

Input

4 3
1 2
1 3
1 4


Output

2

Input

5 4
1 2
2 3
3 4
3 5


Output

3

import java.io.*;

import java.util.*;

import javax.swing.text.InternationalFormatter;

import java.math.*;

public class template {

	static long time = 0, mp = Integer.MAX_VALUE, k = 0, cnt = 0, edge = 0, no = 0;

	static boolean bul = false;
	static long[] ht;
	static long[] dia;
	static boolean[][] b;
	static char[][] g;
	static String sb = "";
	static ArrayList<Integer>[] a;
	static HashSet<Long>[] c;
	public static PrintWriter out;

	static HashMap<Integer, HashSet<Integer>> hm = new HashMap<>();

	static ArrayList<Long> p = new ArrayList<>();

	public static void main(String[] args) throws IOException {

		Scanner scn = new Scanner(System.in);

		int n = scn.nextInt(), m=scn.nextInt();
		
		a=new ArrayList[n+1];
		ht=new long[n+1];
		dia=new long[n+1];
		
		for(int i=1; i<=n; i++)
			a[i]=new ArrayList<>();
		
		while(m--!=0){
			 int x=scn.nextInt(), y=scn.nextInt();
			 a[x].add(y);
			 a[y].add(x);
		}
		
         dfs(1,new HashSet<Integer>());
         
         long mex=Integer.MIN_VALUE;
         
         for(int i=1; i<=n; i++)
        	 mex=Math.max(mex, dia[i]);
         
         System.out.println(mex);
	}

	
	private static void dfs(int v, HashSet<Integer> visited) {
		visited.add(v);
		
		 if(a[v].size() == 1 && v!=1)
			 return ;
		
		 ArrayList<Long> temp=new ArrayList<>();
		
		  for(int nbr:a[v]){
			  
			      if(!visited.contains(nbr))
			    	   dfs(nbr, visited);
			      
			      temp.add(ht[nbr]);
		  }
		
		 Collections.sort(temp);
		 
		 ht[v]=temp.get(temp.size() - 1) + 1;
		 
		 if(temp.size() == 1)
			 dia[v]=ht[v];
		 else
			 dia[v]=temp.get(temp.size() - 1) + temp.get(temp.size() - 2) + 2;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	// _________________________TEMPLATE_____________________________________________________________

	
















	// static class comp implements Comparator<Integer> {
	//
	// @Override
	// public int compare(Integer o1, Integer o2) {
	// return hm.get(o1) - hm.get(o2);
	// }
	//
	// }
	static class pair implements Comparable<pair> {
		int v;
		int wt = 0;

		// int cnt;

		pair(int l, int o) {
			v = l;
			wt = o;
		}

		@Override
		public int compareTo(pair o) {

			return this.v - o.v;

		}
	}

	public static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[100000 + 1]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) throws IOException {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}
			return arr;
		}

		public int[][] nextInt2DArray(int m, int n) throws IOException {
			int[][] arr = new int[m][n];
			for (int i = 0; i < m; i++) {
				for (int j = 0; j < n; j++)
					arr[i][j] = nextInt();
			}
			return arr;
		}

	}

}
