#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

vvi con(100050);
V(bool) visited(100050, false);
vi bw(100050, 0);
bool exr = false;

void dfs(int now, int cost, int past) {
    bw[now] = cost%2;
    rep(i, con[now].size()) {
        if(!visited[con[now][i]]) {
            visited[con[now][i]] = true;
            dfs(con[now][i], cost+1, now);
        } else if(con[now][i] != past) {
            if(bw[con[now][i]]==bw[now]) exr = true;
        }
    }
}

signed main() {
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        con[a].pb(b);
        con[b].pb(a);
    }

    dfs(0, 0, -1);
    
    if(exr) cout << N*(N-1)/2 - M << endl;
    else {
        int b=0, w=0;
        rep(i, N) {
            if(bw[i]==0) b++;
            else w++;
        }
        cout << b*w-M << endl;
    }
        
    
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> graph;

void DFS(int v, int parent_v, vector<int> &depth, vector<int> &parent){
    for(int child_v : graph[v]){
        if(child_v == parent_v) continue;

        depth[child_v] = depth[v] + 1;
        parent[child_v] = v;
        DFS(child_v, v, depth, parent);
    }
}

int main(){
    int n, u, v;
    cin >> n >> u >> v;
    u -= 1;
    v -= 1;
    graph.resize(n);

    for(int i=0; i<n-1; i++){
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<int> depth(n), parent(n);
    DFS(v, -1, depth, parent);

    int init = depth[u];
    int start = u;
    for(int i=0; i<(init-1)/2; i++){
        start = parent[start];
    }
    int dist = depth[start] - (init-1)/2;

    vector<int> depth2(n), parent2(n);
    DFS(start, parent[start], depth2, parent2);

    sort(depth2.begin(),depth2.end());
    reverse(depth2.begin(),depth2.end());

    cout << (init-1)/2 + (depth2[0] + dist - 1) << endl;
    return 0;
}