#include<bits/stdc++.h>
using namespace std;
vector<int> pol[1000005];
vector<int> pol2[1000005];
int pre[1000005];
int post[1000005];
int odl[1000005];
bool odw[1000005];
int par[1000005];
int jmp[200005][23];
int prepost = 0;
void dfs(int a)
{
    pre[a] = prepost;
    prepost++;
    for(auto x:pol2[a])
        dfs(x);
    post[a] = prepost;
    prepost++;
}
bool anc(int a,int b)
{
    return (pre[a] <= pre[b] && post[a] >= post[b]);
}

int lca(int a, int b){
    if(anc(a,b)) return a;
    if(anc(b,a)) return b;
    for(int i=20;i>=0;i--){
        if(!anc(jmp[a][i], b)) a = jmp[a][i];
    }
    return jmp[a][0];
}

void licz_odl(int a)
{
    queue<int> q;
    q.push(0);
    odw[0] = true;
    while(!q.empty())
    {
        int pom = q.front();
        q.pop();
        for(auto x:pol[pom])
            if(!odw[x])
            {
                odw[x] = true;
                odl[x] = odl[pom] + 1;
                q.push(x);
            }
    }
    for(int x=0;x<=a;x++)
        odw[x] = false;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    while(b--)
    {
        int c,d;
        cin>>c>>d;
        pol[c].push_back(d);
        pol[d].push_back(c);
    }
    licz_odl(a);
    for(int x=1;x<a;x++)
    {
        par[x] = -1;
        for(auto y:pol[x])
            if(odl[x] == odl[y] + 1 && (par[x] == -1 || y < par[x]))
                par[x] = y;
        pol2[par[x]].push_back(x);
    }
    dfs(0);
    for(int x=0;x<a;x++)
        jmp[x][0] = par[x];
    for(int j=1;j<=20;j++)
        for(int x=0;x<a;x++)
            jmp[x][j] = jmp[jmp[x][j-1]][j-1];
    vector<pair<int,int>> v;
    for(int x=0;x<a;x++)
        v.push_back({odl[x], x});
    sort(v.begin(),v.end());
    long long ans = 0;
    for(int x=0;x<a-1;x++)
    {
        int pom = lca(v[x].second, v[x+1].second);
        ans += odl[v[x].second];
        ans += odl[v[x+1].second];
        ans -= 2*odl[pom];
        //cout<<v[x].second<<" "<<v[x+1].second<<" "<<pom<<'\n';
    }
    cout<<ans<<'\n';
    return 0;
}
