#include<bits/stdc++.h> #define r register using namespace std; const int N=3e5+5; inline int read() { int X=0,w=0; char ch=0; while(!isdigit(ch)) {w|=ch=='-';ch=getchar();} while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar(); return w?-X:X; } int to[2*N],nxt[2*N],head[N],tot=1; int dfn[N],low[N],time_,id[N],k; bool cut[2*N]; inline void add(int u,int v) { to[++tot]=v,nxt[tot]=head[u],head[u]=tot; } inline void tarjan(int u,int in_edge) { dfn[u]=low[u]=++time_; for (r int i=head[u];i;i=nxt[i]) { int v=to[i]; if (!dfn[v]) { tarjan(v,i); low[u]=min(low[u],low[v]); if (low[v]>dfn[u]) cut[i]=cut[i^1]=1; } else if (i!=(in_edge^1)) low[u]=min(low[u],dfn[v]); } } void dfs(int u) { id[u]=k; for (r int i=head[u];i;i=nxt[i]) { int v=to[i]; if (id[v] || cut[i]) continue; dfs(v); } } vector<int> a[N]; bool vis[N]; int s_, id_; void dfs_ (int u,int s) { vis[u]=1; if (s>s_) s_=s,id_=u; for (r int i=0;i<a[u].size();i++) if (!vis[a[u][i]]) dfs_(a[u][i],s+1); } int main() { int n=read(),m=read(); for (int i=1;i<=m;i++) { int u=read(),v=read(); add(u,v),add(v,u); } for (r int i=1;i<=n;i++) if (!dfn[i]) tarjan(i,0); for (r int i=1;i<=n;i++) if (!id[i]) k++,dfs(i); for (r int i=1;i<=n;i++) for (r int j=head[i];j;j=nxt[j]) if (id[i]!=id[to[j]]) a[id[i]].push_back(id[to[j]]); dfs_(1,1); memset(vis,0,sizeof(vis)); dfs_(id_,1); printf("%d ",s_-1); return 0; }