#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n, u, v;
vector< vector<int> > graphlist(100100, vector<int>());
vector<int> takahashi(100100, -1);
vector<int> aoki(100100, -1);
struct posdata {
    int p; int dist;
};

int main() {
    cin >> n >> u >> v;
    u--; v--;
    takahashi.at(u) = 0; aoki.at(v) = 0;
    for(int i = 0; i < n-1; ++i) {
        int aa, bb; cin >> aa >> bb;
        aa--; bb--;
        graphlist.at(aa).emplace_back(bb);
        graphlist.at(bb).emplace_back(aa);
    }

    queue<posdata> tque;
    posdata tfirst;
    tfirst.p = u; tfirst.dist = 0;
    tque.push(tfirst);
    while(!tque.empty()) {
        posdata now = tque.front();
        tque.pop();
        for(int i = 0; i < (int)graphlist.at(now.p).size(); ++i) {
            int np = graphlist.at(now.p).at(i);
            int ndist = now.dist+1;
            if(takahashi.at(np) == -1) {
                takahashi.at(np) = ndist;
                posdata next;
                next.p = np; next.dist = ndist;
                tque.push(next);
            }
        }
    }

    queue<posdata> aque;
    posdata afirst;
    afirst.p = v; afirst.dist = 0;
    aque.push(afirst);
    while(!aque.empty()) {
        posdata now = aque.front();
        aque.pop();
        for(int i = 0; i < (int)graphlist.at(now.p).size(); ++i) {
            int np = graphlist.at(now.p).at(i);
            int ndist = now.dist+1;
            if(aoki.at(np) == -1) {
                aoki.at(np) = ndist;
                posdata next;
                next.p = np; next.dist = ndist;
                aque.push(next);
            }
        }
    }

    int amax = 0;
    for(int i = 0; i < n; ++i) {
        if(aoki.at(i) > takahashi.at(i)) {
            chmax(amax, aoki.at(i));
        }
    }

    cout << amax-1 << endl;
}
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 200020
using namespace std;
LL read(){
    LL nm=0,fh=1; char cw=getchar();
    for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
    for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
    return nm*fh;
}
LL ans,sum0,sum1,sig;
LL n,m,fs[M],nt[M<<1],to[M<<1],col[M],f[M],sz[M],tmp;
LL fd(LL x){return x==f[x]?x:f[x]=fd(f[x]);}
void link(LL x,LL y){nt[tmp]=fs[x],fs[x]=tmp,to[tmp++]=y;}
void merge(LL x,LL y){x=fd(x),y=fd(y);if(x!=y) f[x]=y,sz[y]+=sz[x];}
bool check(LL x,LL now){
    if(col[x]) return col[x]==now; col[x]=now;
    for(LL i=fs[x];i!=-1;i=nt[i])
        if(!check(to[i],3-now)) return false;
    return true;
}
int main(){
    n=read(),m=read(),memset(fs,-1,sizeof(fs));
    for(LL i=1;i<=n;i++) f[i]=i,sz[i]=1;
    for(LL i=1;i<=m;i++){
        LL x=read(),y=read();
        link(x,y),link(y,x),merge(x,y);
    }
    for(LL i=1;i<=n;i++) if(fd(i)==i&&sz[i]==1) sig++;
    for(LL i=1;i<=n;i++){
        if(fd(i)!=i||sz[i]==1) continue;
        if(check(i,1)) sum0++;
        else sum1++;
    }
    ans+=sig*((n<<1)-1)-sig*(sig-1);
    ans+=((sum0*sum0)<<1);
    ans+=sum1*(sum0<<1)+sum1*sum1;
    printf("%lld\n",ans);
    return 0;
}