#include <bits/stdc++.h>
std::vector<int> adj[100010];
bool visit[100010];
int tMax=0;
int dfs(int curr,int parr,int depth){
if(visit[curr])return 0;
else visit[curr]=true;
int max1=0;
int max2=0;
for(auto to:adj[curr]){
if(to==parr)continue;
int res=dfs(to,curr,depth+1);
if(max1==0)max1=res;
else if(max2==0)max2=res;
else if(res>max1)max2=max1,max1=res;
else if(res>max2)max2=res;
}
tMax=std::max(tMax,depth);
tMax=std::max(tMax,max1+max2-2*depth+1);
return std::max(max1,depth);
}
signed main(){
int n,m;
std::cin >> n >> m;
for(int i=0;i<m;i++){
int a,b;
std::cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
int sum=0;
for(int i=1;i<=n;i++){
tMax=0;
int res = dfs(i,i,1);
//std::cout << tMax << ' ';
sum+=tMax;
}
std::cout << sum;
}