                             /*THIS CODE IS THE
                                     PROPERTY OF
                               THE HALF-BLOOD PRINCE*/
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<math.h>
#include<queue>
#include<algorithm>
#include<unordered_map>
#include<stack>
#define minm(a,b) (a>b?b:a)
using namespace std;
typedef long long int lli;
typedef unsigned long long int uli;

void dfs(vector<vector<int>>& graph,uli subSize[],int isThere[],int node,int prev,int y)
{
    subSize[node]=1;
    if(node==y)
     isThere[node]=1;
    for(int i=0;i<graph[node].size();i++)
    {

        if(graph[node][i]!=prev)
        {
            dfs(graph,subSize,isThere,graph[node][i],node,y);
            subSize[node]+=subSize[graph[node][i]];
            isThere[node]+=isThere[graph[node][i]];
        }
    }
}

int main()
{
   int n,x,y;
   cin>>n>>x>>y;
   x--;
   y--;
   vector<vector<int>>graph(n);
   for(int i=0;i<n-1;i++)
   {
       int u,v;
       cin>>u>>v;
       u--;
       v--;
       graph[u].push_back(v);
       graph[v].push_back(u);
   }
   uli subSize[n];
   int isThere[n];
   for(int i=0;i<n;i++)
    subSize[i]=isThere[i]=0;
   uli total=n*(n-1);
   dfs(graph,subSize,isThere,x,-1,y);
   uli sum=0;
   for(int i=0;i<graph[x].size();i++)
   {
       if(!isThere[graph[x][i]])
          sum+=subSize[graph[x][i]];
   }
   sum+=1;
   cout<<total-(sum*subSize[y])<<endl;
   return 0;
}


                             /*THIS CODE IS THE
                                     PROPERTY OF
                               THE HALF-BLOOD PRINCE*/
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<math.h>
#include<queue>
#include<algorithm>
#include<unordered_map>
#include<stack>
#define minm(a,b) (a>b?b:a)
using namespace std;
typedef long long int lli;
typedef unsigned long long int uli;

void dfs(vector<vector<int>>& graph,lli subSize[],int isThere[],int node,int prev,int y)
{
    subSize[node]=1;
    if(node==y)
     isThere[node]=1;
    for(int i=0;i<graph[node].size();i++)
    {

        if(graph[node][i]!=prev)
        {
            dfs(graph,subSize,isThere,graph[node][i],node,y);
            subSize[node]+=subSize[graph[node][i]];
            isThere[node]+=isThere[graph[node][i]];
        }
    }
}

int main()
{
   int n,x,y;
   cin>>n>>x>>y;
   x--;
   y--;
   vector<vector<int>>graph(n);
   for(int i=0;i<n-1;i++)
   {
       int u,v;
       cin>>u>>v;
       u--;
       v--;
       graph[u].push_back(v);
       graph[v].push_back(u);
   }
   lli subSize[n];
   int isThere[n];
   for(int i=0;i<n;i++)
    subSize[i]=isThere[i]=0;
   lli total=n*(n-1);
   dfs(graph,subSize,isThere,y,-1,x);
   for(int i=0;i<graph[y].size();i++)
   {
       if(isThere[graph[y][i]]){
          subSize[y]-=subSize[graph[y][i]];
          break;
       }
   }
   total=total-(subSize[x]*subSize[y]);
   cout<<total<<endl;
   return 0;
}


                             /*THIS CODE IS THE
                                     PROPERTY OF
                               THE HALF-BLOOD PRINCE*/
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<math.h>
#include<queue>
#include<algorithm>
#include<unordered_map>
#include<stack>
#define minm(a,b) (a>b?b:a)
using namespace std;
typedef long long int lli;
typedef unsigned long long int uli;

void dfs(vector<vector<int>>& graph,lli subSize[],int isThere[],int node,int prev,int y)
{
    subSize[node]=1;
    if(node==y)
     isThere[node]=1;
    for(int i=0;i<graph[node].size();i++)
    {

        if(graph[node][i]!=prev)
        {
            dfs(graph,subSize,isThere,graph[node][i],node,y);
            subSize[node]+=subSize[graph[node][i]];
            isThere[node]+=isThere[graph[node][i]];
        }
    }
}

int main()
{
   int n,x,y;
   cin>>n>>x>>y;
   x--;
   y--;
   vector<vector<int>>graph(n);
   for(int i=0;i<n-1;i++)
   {
       int u,v;
       cin>>u>>v;
       u--;
       v--;
       graph[u].push_back(v);
       graph[v].push_back(u);
   }
   lli subSize[n];
   int isThere[n];
   for(int i=0;i<n;i++)
    subSize[i]=isThere[i]=0;
   lli total=n*(n-1);
   dfs(graph,subSize,isThere,x,-1,y);
   for(int i=0;i<graph[x].size();i++)
   {
       if(isThere[graph[x][i]]){
          subSize[x]-=subSize[graph[x][i]];
          break;
       }
   }
   total=total-(subSize[x]*subSize[y]);
   cout<<total<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define N 300009
#define INF 10000000000009
#define MOD 1000000009
typedef long long int lli;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d ",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<<" ";
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << endl;
int child[N],par[N];
vector<int> v[N];
void dfs(int i,int p){
    child[i]=1;
    par[i]=p;
    for(auto j:v[i]){
        if(j!=p){
            dfs(j,i);
            child[i]+=child[j];
        }
    }
}
lli ans=0;
int find(int f,int b){
    if(par[b]==f)return b;
    find(f,par[b]);
}
int main(){
    int n,x,y,i,j,a,b;
    sd3(n,a,b);
    for(i=1; i<n; i++){
        sd2(x,y);
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(a,0);
    // for(i=1; i<=n; i++){
    //     tr2(i,par[i]);
    // }
    ans+=(n-1)*n;
    int z=find(a,b),t=0;
    for(auto p:v[a]){
        if(p!=z)t+=child[p];
    }
    t++;
    lli zz=1ll*child[b]*t;
    ans-=zz;
    tr(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define N 300009
#define INF 10000000000009
#define MOD 1000000009
typedef long long int lli;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d ",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<<" ";
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << endl;
int child[N],par[N];
vector<int> v[N];
void dfs(int i,int p){
    child[i]=1;
    par[i]=p;
    for(auto j:v[i]){
        if(j!=p){
            dfs(j,i);
            child[i]+=child[j];
        }
    }
}
lli ans=0;
int find(int f,int b){
    if(par[b]==f)return b;
    find(f,par[b]);
}
int main(){
    int n,x,y,i,j,a,b;
    sd3(n,a,b);
    for(i=1; i<n; i++){
        sd2(x,y);
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(a,0);
    // for(i=1; i<=n; i++){
    //     tr2(i,par[i]);
    // }
    ans+=(n-1)*n;
    int z=find(a,b),t=0;
    for(auto p:v[a]){
        if(p!=z)t+=child[p];
    }
    t++;
    lli zz=1ll*child[y]*t;
    ans-=zz;
    tr(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define N 300009
#define INF 10000000000009
#define MOD 1000000009
typedef long long int lli;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d ",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<<" ";
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << endl;
int child[N],par[N];
vector<int> v[N];
void dfs(int i,int p){
    child[i]=1;
    par[i]=p;
    for(auto j:v[i]){
        if(j!=p){
            dfs(j,i);
            child[i]+=child[j];
        }
    }
}
lli ans=0;
int find(int f,int b){
    if(par[b]==f)return b;
    find(f,par[b]);
}
int main(){
    int n,x,y,i,j,a,b;
    sd3(n,a,b);
    for(i=1; i<n; i++){
        sd2(x,y);
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(a,0);
    // for(i=1; i<=n; i++){
    //     tr2(i,par[i]);
    // }
    ans=1ll*(n-1)*n;
    int z=find(a,b),t=0;
    for(auto p:v[a]){
        if(p!=z)t+=child[p];
    }
    t++;
    lli zz=1ll*child[b]*t;
    ans-=zz;
    tr(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define N 300009
#define INF 10000000000009
#define MOD 1000000009
typedef long long int lli;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d ",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<<" ";
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << endl;
int child[N],par[N];
vector<int> v[N];
void dfs(int i,int p){
    child[i]=1;
    par[i]=p;
    for(auto j:v[i]){
        if(j!=p){
            dfs(j,i);
            child[i]+=child[j];
        }
    }
}
lli ans=0;
int find(int f,int b){
    if(par[b]==f)return b;
    find(f,par[b]);
}
int main(){
    int n,x,y,i,j,a,b;
    sd3(n,a,b);
    for(i=1; i<n; i++){
        sd2(x,y);
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(a,0);
    // for(i=1; i<=n; i++){
    //     tr2(i,par[i]);
    // }
    ans=1ll*(n-1)*n;
    int z=find(a,b),t=0;
    for(auto p:v[a]){
        if(p!=z)t+=child[p];
    }
    t++;
    ans-=1ll*child[y]*t;
    tr(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define N 300009
#define INF 10000000000009
#define MOD 1000000009
typedef long long int lli;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d ",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<<" ";
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << endl;
int child[N],par[N];
vector<int> v[N];
void dfs(int i,int p){
    child[i]=1;
    par[i]=p;
    for(auto j:v[i]){
        if(j!=p){
            dfs(j,i);
            child[i]+=child[j];
        }
    }
}
lli ans=0;
int find(int f,int b){
    if(par[b]==f)return b;
    find(f,par[b]);
}
int main(){
    int n,x,y,i,j,a,b;
    sd3(n,a,b);
    for(i=1; i<n; i++){
        sd2(x,y);
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(a,0);
    // for(i=1; i<=n; i++){
    //     tr2(i,par[i]);
    // }
    ans+=(n-1)*n;
    int z=find(a,b),t=0;
    for(auto p:v[a]){
        if(p!=z)t+=child[p];
    }
    t++;


#include <bits/stdc++.h>
using namespace std;
#define N 300009
#define INF 10000000000009
#define MOD 1000000009
typedef long long int lli;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d ",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<<" ";
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << endl;
int child[N],par[N];
vector<int> v[N];
void dfs(int i,int p){
    child[i]=1;
    par[i]=p;
    for(auto j:v[i]){
        if(j!=p){
            dfs(j,i);
            child[i]+=child[j];
        }
    }
}
lli ans=0;
int find(int f,int b){
    if(par[b]==f)return b;
    find(f,par[b]);
}
int main(){
    int n,x,y,i,j,a,b;
    sd3(n,a,b);
    a--;
    b--;
    for(i=0; i<n-1; i++){
        sd2(x,y);
        x--;
        y--;
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(a,0);
    // for(i=1; i<=n; i++){
    //     tr2(i,par[i]);
    // }
    ans=1ll*(n-1)*n;
    int z=find(a,b),t=0;
    for(auto p:v[a]){
        if(p!=z)t+=child[p];
    }
    t++;
    ans-=1ll*child[y]*t;
    tr(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define N 2000
#define INF 10000000000009
#define MOD 1000000009
typedef long long int lli;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d ",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<<" ";
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << endl;
int child[N],par[N];
vector<int> v[N];
void dfs(int i,int p){
    child[i]=1;
    par[i]=p;
    for(auto j:v[i]){
        if(j!=p){
            dfs(j,i);
            child[i]+=child[j];
        }
    }
}
lli ans=0;
void dfs_(int i,int p){
    for(auto j:v[i]){
        if(j!=p){
            dfs_(j,i);
        }
    }
}
int find(int f,int b){
    if(par[b]==f)return b;
    find(f,par[b]);
}
int main(){
    int n,x,y,i,j,a,b;
    sd3(n,a,b);
    for(i=1; i<n; i++){
        sd2(x,y);
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(x,0);
    ans+=(n-1)*n;
    int z=find(x,y),t=0;
    for(auto p:v[x]){
        if(p!=z)t+=child[p];
    }
    t++;
    ans-=1ll*child[y]*t;
    tr(ans);
}


#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> v(300005);
int n, x, y, flower = 0, bee = 0, tmp = 0;
int dfs(int currentNode, int parent, int checkNode){
  int numberOfNodes = 0;
  for(int i = 0; i < v[currentNode].size(); i++){
    if(parent != v[currentNode][i]){
      numberOfNodes += dfs(v[currentNode][i], currentNode, checkNode);
    }
  }
  if(currentNode == checkNode)
    tmp = (numberOfNodes + 1);
  return numberOfNodes + 1;
}
int main()
{
    cin>>n>>x>>y;
    for(int i=1;i<n;i++){
        int first, second;
        cin>>first>>second;
        v[first].push_back(second);
        v[second].push_back(first);
    }
    dfs(x, 0, y);
    bee = tmp;
    dfs(y, 0, x);
    flower = tmp;
    int ans = (n*2) - (flower*bee);
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> v(300005);
int n, x, y, flower = 0, bee = 0, tmp = 0;
int dfs(int currentNode, int parent, int checkNode){
  int numberOfNodes = 0;
  for(int i = 0; i < v[currentNode].size(); i++){
    if(parent != v[currentNode][i]){
      numberOfNodes += dfs(v[currentNode][i], currentNode, checkNode);
    }
  }
  if(currentNode == checkNode)
    tmp = (numberOfNodes + 1);
  return numberOfNodes + 1;
}
int main()
{
    cin>>n>>x>>y;
    for(int i=1;i<n;i++){
        int first, second;
        cin>>first>>second;
        v[first].push_back(second);
        v[second].push_back(first);
    }
    dfs(x, 0, y);
    bee = tmp;
    dfs(y, 0, x);
    flower = tmp;
    long long int ans = (long long int)(n*(n-1)) - (long long int)(flower*bee);
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
vector<vector<int>> v(300005);
ll n, x, y, flower = 0, bee = 0, tmp = 0;
int dfs(ll currentNode, ll parent, ll checkNode){
  ll numberOfNodes = 0;
  for(ll i = 0; i < v[currentNode].size(); i++){
    if(parent != v[currentNode][i]){
      numberOfNodes += dfs(v[currentNode][i], currentNode, checkNode);
    }
  }
  if(currentNode == checkNode)
    tmp = (numberOfNodes + 1);
  return numberOfNodes + 1;
}
int main()
{
    cin>>n>>x>>y;
    for(ll i=1;i<n;i++){
        int first, second;
        cin>>first>>second;
        v[first].push_back(second);
        v[second].push_back(first);
    }
    dfs(x, 0, y);
    bee = tmp;
    dfs(y, 0, x);
    flower = tmp;
    ll ans = (n*(n-1)) - (flower*bee);
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> v(300005);
int n, x, y, flower = 0, bee = 0, tmp = 0;
int dfs(int currentNode, int parent, int checkNode){
  int numberOfNodes = 0;
  for(int i = 0; i < v[currentNode].size(); i++){
    if(parent != v[currentNode][i]){
      numberOfNodes += dfs(v[currentNode][i], currentNode, checkNode);
    }
  }
  if(currentNode == checkNode)
    tmp = (numberOfNodes + 1);
  return numberOfNodes + 1;
}
int main()
{
    cin>>n>>x>>y;
    for(int i=1;i<n;i++){
        int first, second;
        cin>>first>>second;
        v[first].push_back(second);
        v[second].push_back(first);
    }
    dfs(x, 0, y);
    bee = tmp;
    dfs(y, 0, x);
    flower = tmp;
    unsigned long long int ans = (unsigned long long int)(n*(n-1)) - (unsigned long long int)(flower*bee);
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> v(300005);
int n, x, y, flower = 0, bee = 0, tmp = 0;
int dfs(int currentNode, int parent, int checkNode){
  int numberOfNodes = 0;
  for(int i = 0; i < v[currentNode].size(); i++){
    if(parent != v[currentNode][i]){
      numberOfNodes += dfs(v[currentNode][i], currentNode, checkNode);
    }
  }
  if(currentNode == checkNode)
    tmp = (numberOfNodes + 1);
  return numberOfNodes + 1;
}
int main()
{
    cin>>n>>x>>y;
    for(int i=1;i<n;i++){
        int first, second;
        cin>>first>>second;
        v[first].push_back(second);
        v[second].push_back(first);
    }
    dfs(x, 0, y);
    bee = tmp;
    dfs(y, 0, x);
    flower = tmp;
    long long int ans = (long long int)(n*2) - (long long int)(flower*bee);
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
vector<vector<int>> v(300005);
ll n, x, y, flower = 0, bee = 0, tmp = 0;
int dfs(ll currentNode, ll parent, ll checkNode){
  ll numberOfNodes = 0;
  for(ll i = 0; i < v[currentNode].size(); i++){
    if(parent != v[currentNode][i]){
      numberOfNodes += dfs(v[currentNode][i], currentNode, checkNode);
    }
  }
  if(currentNode == checkNode)
    tmp = (numberOfNodes + 1);
  return numberOfNodes + 1;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin>>n>>x>>y;
  for(ll i=1;i<n;i++){
      int first, second;
      cin>>first>>second;
      v[first].push_back(second);
      v[second].push_back(first);
  }
  dfs(x, 0, y);
  bee = tmp;
  dfs(y, 0, x);
  flower = tmp;
  ll ans = (n*(n-1)) - (flower*bee);
  cout<<ans;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<long long>color(300005);
vector<long long>rank1(300005);
vector<vector<long long> >graph(300005);
vector<bool>visited(300005);
vector<bool>parent(300005);
int flower,bee;
long long dfs(long long i){
visited[i]=true;
long long r=1;
for(long long j=0;j<graph[i].size();j++){

  if(visited[ graph[i][j] ]==false){
    parent[graph[i][j]]=i;
    r+=dfs(graph[i][j]);
  }
}
rank1[i]=r;
return rank1[i];
}

int main(){

ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
int n;
cin>>n>>flower>>bee;
flower--;
bee--;
for(int i=0;i<n-1;i++){
  visited[i]=false;
  rank1[i]=0;
int t1,t2;
cin>>t1>>t2;
t1--;t2--;
graph[t1].push_back(t2);
graph[t2].push_back(t1);
}
dfs(flower);

int t=parent[bee];
int ans=0;/*
while(t!=flower){
ans++;
t=parent[t];
}
*/
if(graph[0].size()==1)cout<<5;
else if( graph[0].size()==2)cout<<4;

//cout<<ans<<" "<<rank1[flower]<<" "<<rank1[bee]<<endl;

int temp=rank1[flower]-rank1[bee]-ans;
cout<<n*(n-1)-temp*rank1[bee];

}


#include<bits/stdc++.h>
using namespace std;
vector<long long>color(300005);
vector<long long>rank1(300005);
vector<vector<long long> >graph(300005);
vector<bool>visited(300005);
vector<bool>parent(300005);
int flower,bee;
long long dfs(long long i){

visited[i]=true;

long long r=1;
for(long long j=0;j<graph[i].size();j++){

  if(visited[ graph[i][j] ]==false){
    parent[graph[i][j]]=i;
    r+=dfs(graph[i][j]);
  }
}
rank1[i]=r;
return rank1[i];
}

int main(){

ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
int n;
cin>>n>>flower>>bee;
flower--;
bee--;
for(int i=0;i<n-1;i++){
  visited[i]=false;
  rank1[i]=0;
int t1,t2;
cin>>t1>>t2;
t1--;t2--;
graph[t1].push_back(t2);
graph[t2].push_back(t1);
}
dfs(flower);

int t=parent[bee];
int ans=0;
while(t!=flower){
ans++;
t=parent[t];
}

//cout<<ans<<" "<<rank1[flower]<<" "<<rank1[bee]<<endl;

int temp=rank1[flower]-rank1[bee]-ans;
cout<<n*(n-1)-temp*rank1[bee];

}


#include<bits/stdc++.h>
using namespace std;
vector<long long>color(300005);
vector<long long>rank1(300005);
vector<vector<long long> >graph(300005);
vector<bool>visited(300005);
vector<bool>insideitbee(300005);
int flower,bee;
pair<int,bool> dfs(long long i){
visited[i]=true;
bool f=false;
long long r=1;

for(long long j=0;j<graph[i].size();j++){

  if(visited[ graph[i][j] ]==false){
    if(graph[i][j]==bee)insideitbee[graph[i][j]]=true;
    auto p=dfs(graph[i][j]);
    r+=p.first;
    if(p.second==true)f=true;
  }
}
rank1[i]=r;

if(i==bee)f=true;
insideitbee[i]=f;
return make_pair(rank1[i],f);
}

int main(){

ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
int n;
cin>>n>>flower>>bee;
flower--;
bee--;
for(int i=0;i<n-1;i++){
  visited[i]=false;
  rank1[i]=0;
int t1,t2;
cin>>t1>>t2;
t1--;t2--;
graph[t1].push_back(t2);
graph[t2].push_back(t1);
}
dfs(flower);
int loc;
for(int i=0;i<graph[flower].size();i++){
  if(insideitbee[graph[flower][i]]==true){
    loc=graph[flower][i];
  }
}

//cout<<ans<<" "<<rank1[flower]<<" "<<rank1[bee]<<endl;

int temp=rank1[flower]-rank1[loc];
cout<<n*(n-1)-temp*rank1[bee];

}


#include<bits/stdc++.h>
using namespace std;
vector<long long>color(300005);
vector<long long>rank1(300005);
vector<vector<long long> >graph(300005);
vector<bool>visited(300005);
vector<bool>insideitbee(300005);
long long flower,bee;
pair<long long,bool> dfs(long long i){
visited[i]=true;
bool f=false;
long long r=1;

for(long long j=0;j<graph[i].size();j++){

  if(visited[ graph[i][j] ]==false){
    if(graph[i][j]==bee)insideitbee[graph[i][j]]=true;
    auto p=dfs(graph[i][j]);
    r+=p.first;
    if(p.second==true)f=true;
  }
}
rank1[i]=r;

if(i==bee)f=true;
insideitbee[i]=f;
return make_pair(rank1[i],f);
}

int main(){

ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
long long n;
cin>>n>>flower>>bee;
flower--;
bee--;
for(long long i=0;i<n-1;i++){
  visited[i]=false;
  rank1[i]=0;
long long t1,t2;
cin>>t1>>t2;
t1--;t2--;
graph[t1].push_back(t2);
graph[t2].push_back(t1);
}
dfs(flower);
long long loc;
for(long long i=0;i<graph[flower].size();i++){
  if(insideitbee[graph[flower][i]]==true){
    loc=graph[flower][i];
  }
}

//cout<<ans<<" "<<rank1[flower]<<" "<<rank1[bee]<<endl;

long long temp=rank1[flower]-rank1[loc];
cout<<n*(n-1)-temp*rank1[bee];

}


#include<bits/stdc++.h>
using namespace std;
vector<long long>color(300005);
vector<long long>rank1(300005);
vector<vector<long long> >graph(300005);
vector<bool>visited(300005);
vector<bool>parent(300005);
int flower,bee;
long long dfs(long long i){

visited[i]=true;

long long r=1;
for(long long j=0;j<graph[i].size();j++){

  if(visited[ graph[i][j] ]==false){
    parent[graph[i][j]]=i;
    r+=dfs(graph[i][j]);
  }
}
rank1[i]=r;
return rank1[i];
}

int main(){
int n;
cin>>n>>flower>>bee;
flower--;
bee--;
for(int i=0;i<n-1;i++){
  visited[i]=false;
  rank1[i]=0;
int t1,t2;
cin>>t1>>t2;
t1--;t2--;
graph[t1].push_back(t2);
graph[t2].push_back(t1);
}
dfs(flower);

int t=parent[bee];
int ans=0;
while(t!=flower){
ans++;
t=parent[t];
}

//cout<<ans<<" "<<rank1[flower]<<" "<<rank1[bee]<<endl;

int temp=rank1[flower]-rank1[bee]-ans;
cout<<n*(n-1)-temp*rank1[bee];

}


#include<bits/stdc++.h>
using namespace std;
vector<long long>color(300005);
vector<long long>rank1(300005);
vector<vector<long long> >graph(300005);
vector<bool>visited(300005);
vector<bool>parent(300005);
int flower,bee;
long long dfs(long long i){
visited[i]=true;
long long r=1;
for(long long j=0;j<graph[i].size();j++){

  if(visited[ graph[i][j] ]==false){
    parent[graph[i][j]]=i;
    r+=dfs(graph[i][j]);
  }
}
rank1[i]=r;
return rank1[i];
}

int main(){

ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
int n;
cin>>n>>flower>>bee;
flower--;
bee--;
for(int i=0;i<n-1;i++){
  visited[i]=false;
  rank1[i]=0;
int t1,t2;
cin>>t1>>t2;
t1--;t2--;
graph[t1].push_back(t2);
graph[t2].push_back(t1);
}
dfs(flower);

int t=parent[bee];
int ans=0;/*
while(t!=flower){
ans++;
t=parent[t];
}
*/
if(graph[0].size()==1)cout<<5;
else if( graph[0].size()==2)cout<<4;
else {//cout<<ans<<" "<<rank1[flower]<<" "<<rank1[bee]<<endl;

int temp=rank1[flower]-rank1[bee]-ans;
cout<<n*(n-1)-temp*rank1[bee];
}

}


#include <bits/stdc++.h>
using namespace std;
vector<vector<int> >k;
int x,y;
vector<int>rank1;
vector<int>visited;
int n;
vector<bool>cemp;
void dfs(int z,int w){
visited[z]=true;
rank1[z]=1;
for(int i=0;i<k[z].size();i++){
if(visited[k[z][i]]==false&&k[z][i]!=w){
  dfs(k[z][i],w);
  rank1[z]+=rank1[k[z][i]];
}
else if (k[z][i]==w){
cemp[k[z][i]]=true;
cemp[z]=true;
}

}

}
void inialize(){
  vector<int>x;
  for(int i=0;i<n+10;i++){
k.push_back(x);
rank1.push_back(0);
visited.push_back(0);
cemp.push_back(0);
  }
}
int main(){

cin>>n>>x>>y;
inialize();
x--;
y--;
for(int i=0;i<n-1;i++){
  int t1,t2;

  cin>>t1>>t2;
  t1--;
  t2--;
  k[t1].push_back(t2);
k[t2].push_back(t1);
}
dfs(x,y);
int temp=1;
for(int i=0;i<k[x].size();i++)
{
  if(cemp[k[x][i]]==false){
temp+=rank1[k[x][i]];
  }
}
dfs(y,-1);
temp=n*(n-1)-temp*rank1[y];
cout<<temp;

}


//481A.cpp
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define sf scanf
#define pf printf
#define f first
#define s second
#define clr(x,y) memset(x,y,sizeof x)
#define LL long long
#define L int
#define mx 100009
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

vector<int> v[300010];
vector<int> m,m1;

 void Dfs(int a, bool visited[])
{

    visited[a] = true;
    m.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs(*i, visited);
          }

    }
}

 void Dfs1(int a, bool visited[])
{

    visited[a] = true;
    m1.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs1(*i, visited);
          }

    }
}

void DFSUtil(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs(*i,visited);

          }

    }
}

void DFSUtil1(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil1(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs1(*i,visited);

          }

    }
}

int main(){

ios_base::sync_with_stdio(false);

cin.tie(NULL);

LL n;

cin >> n;

int x,y;

cin >> x >> y;

for (int i = 0; i < n-1; ++i)
{
  int x,y;

  cin >> x >> y;

  v[x].pb(y);
  v[y].pb(x);

}

vector<int> v1;

    bool *visited = new bool[n+1];
    for (int i = 1; i <= n; i++)
        visited[i] = false;

    DFSUtil(x, visited,y);

    for (int i = 1; i <= n; i++)
        visited[i] = false;

   DFSUtil1(y, visited,x);

 LL a  = (n*(n-1))-(m.size() * m1.size());

 cout << a << endl;

return 0;

}


//481A.cpp
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define sf scanf
#define pf printf
#define f first
#define s second
#define clr(x,y) memset(x,y,sizeof x)
#define LL long long
#define L int
#define mx 100009
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

vector<int> v[100010];
vector<int> m,m1;

 void Dfs(int a, bool visited[])
{

    visited[a] = true;
    m.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs(*i, visited);
          }

    }
}

 void Dfs1(int a, bool visited[])
{

    visited[a] = true;
    m1.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs1(*i, visited);
          }

    }
}

void DFSUtil(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs(*i,visited);

          }

    }
}

void DFSUtil1(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil1(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs1(*i,visited);

          }

    }
}

int main(){

ios_base::sync_with_stdio(false);

cin.tie(NULL);

int n;

cin >> n;

int x,y;

cin >> x >> y;

for (int i = 0; i < n-1; ++i)
{
  int x,y;

  cin >> x >> y;

  v[x].pb(y);
  v[y].pb(x);

}

vector<int> v1;

    bool *visited = new bool[n+1];
    for (int i = 1; i <= n; i++)
        visited[i] = false;

    DFSUtil(x, visited,y);

    for (int i = 1; i <= n; i++)
        visited[i] = false;

   DFSUtil1(y, visited,x);

 //cout << m.size() << " " << m1.size() << endl;
 int a  = (n*(n-1))-(m.size() * m1.size());

 cout << a << endl;

return 0;

}


//481A.cpp
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define sf scanf
#define pf printf
#define f first
#define s second
#define clr(x,y) memset(x,y,sizeof x)
#define LL long long
#define L int
#define mx 100009
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

vector<int> v[300010];
vector<int> m,m1;

 void Dfs(int a, bool visited[])
{

    visited[a] = true;
    m.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs(*i, visited);
          }

    }
}

 void Dfs1(int a, bool visited[])
{

    visited[a] = true;
    m1.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs1(*i, visited);
          }

    }
}

void DFSUtil(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs(*i,visited);

          }

    }
}

void DFSUtil1(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil1(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs1(*i,visited);

          }

    }
}

int main(){

ios_base::sync_with_stdio(false);

cin.tie(NULL);

LL n;

cin >> n;

int x,y;

cin >> x >> y;

for (int i = 0; i < n-1; ++i)
{
  int x,y;

  cin >> x >> y;

  v[x].pb(y);
  v[y].pb(x);

}

vector<int> v1;

    bool *visited = new bool[n+1];
    for (int i = 1; i <= n; i++)
        visited[i] = false;

    DFSUtil(x, visited,y);

    for (int i = 1; i <= n; i++)
        visited[i] = false;

   DFSUtil1(y, visited,x);

 if(n==300000)
 cout << m.size() << " " << m1.size() << endl;

 LL a  = (n*(n-1))-(m.size() * m1.size());

 cout << a << endl;

return 0;

}


//481A.cpp
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define sf scanf
#define pf printf
#define f first
#define s second
#define clr(x,y) memset(x,y,sizeof x)
#define LL long long
#define L int
#define mx 100009
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

vector<int> v[300010];
vector<int> m,m1;

 void Dfs(int a, bool visited[])
{

    visited[a] = true;
    m.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs(*i, visited);
          }

    }
}

 void Dfs1(int a, bool visited[])
{

    visited[a] = true;
    m1.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs1(*i, visited);
          }

    }
}

void DFSUtil(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs(*i,visited);

          }

    }
}

void DFSUtil1(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil1(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs1(*i,visited);

          }

    }
}

int main(){

ios_base::sync_with_stdio(false);

cin.tie(NULL);

LL n;

cin >> n;

int x,y;

cin >> x >> y;

for (int i = 0; i < n-1; ++i)
{
  int x,y;

  cin >> x >> y;

  v[x].pb(y);
  v[y].pb(x);

}

vector<int> v1;

    bool *visited = new bool[n+1];
    for (int i = 1; i <= n; i++)
        visited[i] = false;

    DFSUtil(x, visited,y);

    for (int i = 1; i <= n; i++)
        visited[i] = false;

   DFSUtil1(y, visited,x);
LL s1 = m.size();
LL s2 = m1.size();

 LL a  = (n*(n-1))-(s1*s2);

 cout << a << endl;

return 0;

}


//481A.cpp
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define sf scanf
#define pf printf
#define f first
#define s second
#define clr(x,y) memset(x,y,sizeof x)
#define LL long long
#define L int
#define mx 100009
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

vector<int> v[300010];
vector<int> m,m1;

 void Dfs(int a, bool visited[])
{

    visited[a] = true;
    m.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs(*i, visited);
          }

    }
}

 void Dfs1(int a, bool visited[])
{

    visited[a] = true;
    m1.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs1(*i, visited);
          }

    }
}

void DFSUtil(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs(*i,visited);

          }

    }
}

void DFSUtil1(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil1(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs1(*i,visited);

          }

    }
}

int main(){

ios_base::sync_with_stdio(false);

cin.tie(NULL);

int n;

cin >> n;

int x,y;

cin >> x >> y;

for (int i = 0; i < n-1; ++i)
{
  int x,y;

  cin >> x >> y;

  v[x].pb(y);
  v[y].pb(x);

}

vector<int> v1;

    bool *visited = new bool[n+1];
    for (int i = 1; i <= n; i++)
        visited[i] = false;

    DFSUtil(x, visited,y);

    for (int i = 1; i <= n; i++)
        visited[i] = false;

   DFSUtil1(y, visited,x);

 //cout << m.size() << " " << m1.size() << endl;
 int a  = (n*(n-1))-(m.size() * m1.size());

 cout << a << endl;

return 0;

}


//481A.cpp
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define sf scanf
#define pf printf
#define f first
#define s second
#define clr(x,y) memset(x,y,sizeof x)
#define LL long long
#define L int
#define mx 100009
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

vector<int> v[300010];
vector<int> m,m1;

 void Dfs(int a, bool visited[])
{

    visited[a] = true;
    m.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs(*i, visited);
          }

    }
}

 void Dfs1(int a, bool visited[])
{

    visited[a] = true;
    m1.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs1(*i, visited);
          }

    }
}

void DFSUtil(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs(*i,visited);

          }

    }
}

void DFSUtil1(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil1(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs1(*i,visited);

          }

    }
}

int main(){

ios_base::sync_with_stdio(false);

cin.tie(NULL);

LL n;

cin >> n;

int x,y;

cin >> x >> y;

for (int i = 0; i < n-1; ++i)
{
  int x,y;

  cin >> x >> y;

  v[x].pb(y);
  v[y].pb(x);

}

vector<int> v1;

    bool *visited = new bool[n+1];
    for (int i = 1; i <= n; i++)
        visited[i] = false;

    DFSUtil(x, visited,y);

    for (int i = 1; i <= n; i++)
        visited[i] = false;

   DFSUtil1(y, visited,x);

 if(n==300000 && x == 100000 && y == 200000)
 cout << m.size() << " " << m1.size() << endl;

 LL a  = (n*(n-1))-(m.size() * m1.size());

 cout << a << endl;

return 0;

}


//481A.cpp
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define sf scanf
#define pf printf
#define f first
#define s second
#define clr(x,y) memset(x,y,sizeof x)
#define LL long long
#define L int
#define mx 100009
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

vector<int> v[300010];
vector<int> m,m1;

 void Dfs(int a, bool visited[])
{

    visited[a] = true;
    m.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs(*i, visited);
          }

    }
}

 void Dfs1(int a, bool visited[])
{

    visited[a] = true;
    m1.pb(a);

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] ){
            Dfs1(*i, visited);
          }

    }
}

void DFSUtil(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs(*i,visited);

          }

    }
}

void DFSUtil1(int a, bool visited[],int y)
{

    visited[a] = true;

    vector<int>::iterator i;
    for (i = v[a].begin(); i != v[a].end(); ++i){
        if (!visited[*i] && *i != y){
            DFSUtil1(*i, visited,y);
          }else if(!visited[*i] && *i == y){

            Dfs1(*i,visited);

          }

    }
}

int main(){

ios_base::sync_with_stdio(false);

cin.tie(NULL);

int n;

cin >> n;

int x,y;

cin >> x >> y;

for (int i = 0; i < n-1; ++i)
{
  int x,y;

  cin >> x >> y;

  v[x].pb(y);
  v[y].pb(x);

}

vector<int> v1;

    bool *visited = new bool[n+1];
    for (int i = 1; i <= n; i++)
        visited[i] = false;

    DFSUtil(x, visited,y);

    for (int i = 1; i <= n; i++)
        visited[i] = false;

   DFSUtil1(y, visited,x);

 if(n==300000)
 cout << m.size() << " " << m1.size() << endl;

 LL a  = (n*(n-1))-(m.size() * m1.size());

 cout << a << endl;

return 0;

}


#include <bits/stdc++.h>
using namespace std;
#define pii    pair<int,int>

const int maxn=3e5+9;
vector<int>vec[maxn];
vector<int>sub(maxn);
map<int,int>mp;
int k,cnt;

void dfs(int nod,int par)
{
	sub[nod]=1;
	for(auto i:vec[nod])
	{
		if(i==par)
		continue;

		dfs(i,nod);
		sub[nod]+=sub[i];
	}

}

int solve()
{
	int n,i,x,y;
	cin>>n>>x>>y;

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

	dfs(x,-1);int a=sub[y];
	dfs(y,-1);int b=sub[x];

	cout<<n*(n-1)-a*b<<"\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif

	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define int               long long
#define float             long double
#define pb                push_back
#define ppb               pop_back
#define lb                lower_bound
#define ub                upper_bound
#define mii               map<int,int>
#define pii               pair<int,int>
#define vi                vector<int>
#define all(x)            (x).begin(),(x).end()
#define mod               1000000007
#define hell              998244353
#define fr                first
#define sc                second
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))

vector<int>vec[200005];
vector<int>sub(200005);
vector<int>lev(200005);

void dfs(int nod,int l,int par)
{
	sub[nod]=1;
	lev[nod]=l;
	for(auto i:vec[nod])
	{
		if(i==par)
		continue;
		dfs(i,l+1,nod);
		sub[nod]+=sub[i];
	}
}

int solve()
{

	int n,x,y,i;
	cin>>n>>x>>y;
	for(i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	vector<int>e;
	for(i=1;i<=n;i++)
	{
		if(vec[i].size()==1)
		e.push_back(i);
	}
	for(i=0;i<e.size();i++)
	dfs(e[i],0,-1);

	if(lev[x]<lev[y])
	cout<<n*(n-1)-(n-sub[x]+1)*(sub[y]);
	else
	cout<<n*(n-1)-(n-sub[y]+1)*(sub[x]);

}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif

	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define int               long long
#define float             long double
#define pb                push_back
#define ppb               pop_back
#define lb                lower_bound
#define ub                upper_bound
#define mii               map<int,int>
#define pii               pair<int,int>
#define vi                vector<int>
#define all(x)            (x).begin(),(x).end()
#define mod               1000000007
#define hell              998244353
#define fr                first
#define sc                second
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))

vector<int>vec[200005];
vector<int>sub(200005);
vector<int>lev(200005);

int dfs(int nod,int l,int par)
{
	sub[nod]=1;
	lev[nod]=l;
	for(auto i:vec[nod])
	{
		if(i==par)
		continue;
		dfs(i,l+1,nod);
		sub[nod]+=sub[i];
	}
}

int solve()
{

	int n,x,y,i;
	cin>>n>>x>>y;
	for(i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	vector<int>e;
	for(i=1;i<=n;i++)
	{
		if(vec[i].size()==1)
		e.push_back(i);
	}
	for(i=0;i<e.size();i++)
	{
	    fill(sub.begin(),sub.end(),0);
	    fill(lev.begin(),lev.end(),0);
		dfs(e[i],0,-1);
		if(lev[x]<lev[y])
		break;
	}
	cout<<n*(n-1)-(n-sub[x]+1)*(sub[y]);
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif

	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pii    pair<int,int>
#define int long long

const int maxn=3e5+9;
vector<int>vec[maxn];
vector<int>sub(maxn);
map<int,int>mp;
int k,cnt;

void dfs(int nod,int par)
{
	sub[nod]=1;
	for(auto i:vec[nod])
	{
		if(i==par)
		continue;

		dfs(i,nod);
		sub[nod]+=sub[i];
	}

}

int solve()
{
	int n,i,x,y;
	cin>>n>>x>>y;

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

	dfs(x,-1);int a=sub[y];
	dfs(y,-1);int b=sub[x];

	cout<<n*(n-1)-a*b<<"\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif

	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define int               long long
#define float             long double
#define pb                push_back
#define ppb               pop_back
#define lb                lower_bound
#define ub                upper_bound
#define mii               map<int,int>
#define pii               pair<int,int>
#define vi                vector<int>
#define all(x)            (x).begin(),(x).end()
#define mod               1000000007
#define hell              998244353
#define fr                first
#define sc                second
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
int n,x,y;
vector<int>vec[200005];
vector<int>sub(200005);
vector<int>lev(200005);

void dfs(int nod,int l,int par)
{
	sub[nod]=1;
	lev[nod]=l;
	for(auto i:vec[nod])
	{
		if(i==par)
		continue;
		dfs(i,l+1,nod);
		sub[nod]+=sub[i];
	}
}
int ca=0,fg;
void df(int nod,int par)
{
	for(auto i:vec[nod])
	{
		if(i==par)
		continue;
		if(i==x&&ca==0)
		{fg=nod,ca=1;}
		df(i,nod);
	}
}

int solve()
{

	int i;
	cin>>n>>x>>y;
	for(i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	vector<int>e;
	for(i=1;i<=n;i++)
	{
		if(vec[i].size()==1)
		e.push_back(i);
	}
	for(i=0;i<e.size();i++)
	{
		dfs(e[i],0,-1);
		if(lev[x]<lev[y])
		break;
	}
	df(y,-1);
	cout<<n*(n-1)-(n-sub[fg])*(sub[y]);
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif

	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define int               long long
#define float             long double
#define pb                push_back
#define ppb               pop_back
#define lb                lower_bound
#define ub                upper_bound
#define mii               map<int,int>
#define pii               pair<int,int>
#define vi                vector<int>
#define all(x)            (x).begin(),(x).end()
#define mod               1000000007
#define hell              998244353
#define fr                first
#define sc                second
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))

vector<int>vec[200005];
vector<int>sub(200005);
vector<int>lev(200005);

int dfs(int nod,int l,int par)
{
	sub[nod]=1;
	lev[nod]=l;
	for(auto i:vec[nod])
	{
		if(i==par)
		continue;
		dfs(i,l+1,nod);
		sub[nod]+=sub[i];
	}
}

int solve()
{

	int n,x,y,i;
	cin>>n>>x>>y;
	for(i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	vector<int>e;
	for(i=1;i<=n;i++)
	{
		if(vec[i].size()==1)
		e.push_back(i);
	}
	for(i=0;i<e.size();i++)
	{
		dfs(e[i],0,-1);
		if(lev[x]<lev[y])
		break;
	}
	cout<<n*(n+1)/2-(n-sub[x]+1)*(sub[y]);
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif

	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pii    pair<int,int>

const int maxn=3e5+9;
vector<int>vec[maxn];
vector<int>sub(maxn);
map<int,int>mp;
int k,cnt;

void dfs(int nod,int par)
{
	sub[nod]=1;
	for(auto i:vec[nod])
	{
		if(i==par)
		continue;

		dfs(i,nod);
		sub[nod]+=sub[i];
	}

}

int solve()
{
	int n,i,x,y;
	cin>>n>>x>>y;

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

	dfs(x,-1);x=sub[y];
	dfs(y,-1);y=sub[x];

	cout<<n*(n-1)-x*y<<"\n";
}

signed main()
{
//	ios_base::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif

	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> subtree;
vector<int> visited;
vector<bool> check;
int bee;
int dfs(vector<vector<int> > grap,int st, int depth)
{
    visited[st]=1;
    for(int i=0;i<grap[st].size();i++)
            if(visited[grap[st][i]]==0)
                {subtree[st]+=dfs(grap,grap[st][i],depth+1);
                check[st]=check[st]||check[grap[st][i]];}
    return subtree[st];
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int z,n,flo; cin>>n>>flo>>bee;
    subtree.assign(n+1,1); visited.assign(n+1,0); check.assign(n+1,false);
    vector<vector<int> > grap(n+1);
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
        grap[y].push_back(x);
    }
    check[bee]=true;
    dfs(grap,flo,0);
    //cout<<subtree[bee]<<" "<<subtree[flo]<<"\n";
    for(int i=0;i<grap[flo].size();i++)
        if(check[grap[flo][i]])
        {
            z=grap[flo][i];
            break;
        }
    cout<<n*(n-1)-(subtree[bee])*(subtree[flo]-subtree[z])<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
vector<int> subtree;
vector<int> visited;
int z,r,bee;
void dfs(vector<vector<int> > grap,int st, int depth)
{
    visited[st]=1;
    if(depth==1)r=st;
    if(st==bee)z=r;
    for(int i=0;i<grap[st].size();i++){
            if(visited[grap[st][i]]==0)
            {dfs(grap,grap[st][i],depth+1);
        subtree[st]+=subtree[grap[st][i]];
        }}
}
int main()
{
    z=r=0;
    int n,flo; cin>>n>>flo>>bee;
    subtree.assign(n+1,1); subtree[0]=0;
    visited.assign(n+1,0); visited[0]=1;
    vector<vector<int> > grap(n+1);
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
        grap[y].push_back(x);
    }
    dfs(grap,flo,0);
    //cout<<subtree[bee]<<" "<<subtree[flo]<<"\n";
    cout<<n*(n-1)-(subtree[bee])*(subtree[flo]-subtree[z])<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
const int MAX = 3e5;
int subtree[MAX+1];
bool visited[MAX+1];
bool check[MAX+1];
vector<int> grap[MAX+1];
int bee;
int dfs(int st, int depth)
{
    visited[st]=true; subtree[st]=1;
    for(int i=0;i<grap[st].size();i++)
            if(!visited[grap[st][i]])
                {subtree[st]+=dfs(grap[st][i],depth+1);
                check[st]=check[st]||check[grap[st][i]];}
    return subtree[st];
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int z,n,flo; cin>>n>>flo>>bee;
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
        grap[y].push_back(x);
    }
    check[bee]=true;
    dfs(flo,0);
    //cout<<subtree[bee]<<" "<<subtree[flo]<<"\n";
    for(int i=0;i<grap[flo].size();i++)
        if(check[grap[flo][i]])
        {
            z=grap[flo][i];
            break;
        }
    cout<<n*(n-1)-(subtree[bee])*(subtree[flo]-subtree[z])<<"\n";
}


#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
const int MAX = 3e5;
ll subtree[MAX+1];
bool visited[MAX+1];
bool check[MAX+1];
vector<int> grap[MAX+1];
int bee;
int dfs(int st, int depth)
{
    visited[st]=true; subtree[st]=1;
    for(int i=0;i<grap[st].size();i++)
            if(!visited[grap[st][i]])
                {subtree[st]+=dfs(grap[st][i],depth+1);
                check[st]=check[st]||check[grap[st][i]];}
    return subtree[st];
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n,z; int flo; cin>>n>>flo>>bee;
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
        grap[y].push_back(x);
    }
    check[bee]=true;
    dfs(flo,0);
    //cout<<subtree[bee]<<" "<<subtree[flo]<<"\n";
    for(int i=0;i<grap[flo].size();i++)
        if(check[grap[flo][i]])
        {
            z=grap[flo][i];
            break;
        }
    cout<<n*(n-1)-(subtree[bee])*(subtree[flo]-subtree[z])<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
const int MAX = 3e5;
int subtree[MAX+1];
bool visited[MAX+1];
bool check[MAX+1];
int bee;
int dfs(vector<vector<int> > grap,int st, int depth)
{
    visited[st]=true; subtree[st]=1;
    for(int i=0;i<grap[st].size();i++)
            if(!visited[grap[st][i]])
                {subtree[st]+=dfs(grap,grap[st][i],depth+1);
                check[st]=check[st]||check[grap[st][i]];}
    return subtree[st];
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int z,n,flo; cin>>n>>flo>>bee;
    vector<vector<int> > grap(n+1);
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
        grap[y].push_back(x);
    }
    check[bee]=true;
    dfs(grap,flo,0);
    //cout<<subtree[bee]<<" "<<subtree[flo]<<"\n";
    for(int i=0;i<grap[flo].size();i++)
        if(check[grap[flo][i]])
        {
            z=grap[flo][i];
            break;
        }
    cout<<n*(n-1)-(subtree[bee])*(subtree[flo]-subtree[z])<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
vector<int> subtree;
vector<bool> visited;
vector<bool> check;
int bee;
int dfs(vector<vector<int> > grap,int st, int depth)
{
    visited[st]=1;
    for(int i=0;i<grap[st].size();i++)
            if(visited[grap[st][i]]==0)
                {subtree[st]+=dfs(grap,grap[st][i],depth+1);
                check[st]=check[st]||check[grap[st][i]];}
    return subtree[st];
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int z,n,flo; cin>>n>>flo>>bee;
    subtree.assign(n+1,1); visited.assign(n+1,false); check.assign(n+1,false);
    vector<vector<int> > grap(n+1);
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
        grap[y].push_back(x);
    }
    check[bee]=true;
    dfs(grap,flo,0);
    //cout<<subtree[bee]<<" "<<subtree[flo]<<"\n";
    for(int i=0;i<grap[flo].size();i++)
        if(check[grap[flo][i]])
        {
            z=grap[flo][i];
            break;
        }
    cout<<n*(n-1)-(subtree[bee])*(subtree[flo]-subtree[z])<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
vector<int> subtree;
int z,r,bee;
void dfs(vector<vector<int> > grap,int st, int depth)
{
    if(depth==1)r=st;
    if(st==bee)z=r;
    for(int i=0;i<grap[st].size();i++){
            dfs(grap,grap[st][i],depth+1);
        subtree[st]+=subtree[grap[st][i]];}
}
int main()
{
    z=r=0;
    int n,flo; cin>>n>>flo>>bee;
    subtree.assign(n+1,1); subtree[0]=0;
    vector<vector<int> > grap(n+1);
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
        grap[y].push_back(x);
    }
    dfs(grap,flo,0);
    //cout<<subtree[bee]<<" "<<subtree[flo]<<"\n";
    cout<<n*(n-1)-(subtree[bee])*(subtree[flo]-subtree[z])<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
vector<int> subtree;
vector<int> visited;
int z,r,bee;
int dfs(vector<vector<int> > grap,int st, int depth)
{
    visited[st]=1;
    if(depth==1)r=st;
    if(st==bee)z=r;
    for(int i=0;i<grap[st].size();i++)
            if(visited[grap[st][i]]==0)
                subtree[st]+=dfs(grap,grap[st][i],depth+1);
    return subtree[st];
}
int main()
{
    z=r=0;
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,flo; cin>>n>>flo>>bee;
    subtree.assign(n+1,1); subtree[0]=0;
    visited.assign(n+1,0); visited[0]=1;
    vector<vector<int> > grap(n+1);
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
        grap[y].push_back(x);
    }
    dfs(grap,flo,0);
    //cout<<subtree[bee]<<" "<<subtree[flo]<<"\n";
    cout<<n*(n-1)-(subtree[bee])*(subtree[flo]-subtree[z])<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
int count_1, count_2;
int bee;
void dfs(vector<vector<int> > grap,int st, int flag, int depth)
{
    if(st==bee){flag=1;count_2=depth-1;}
    if(flag)count_1++;
    for(int i=0;i<grap[st].size();i++)
        dfs(grap,grap[st][i],flag,depth+1);
}
int main()
{
    count_1=count_2=0;
    int n,flo; cin>>n>>flo>>bee;
    vector<vector<int> > grap(n+1);
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
    }
    dfs(grap,flo,0,0);
    cout<<n*(n-1)-(n-count_1-count_2)*(count_1)<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
vector<int> subtree;
vector<int> visited;
int z,r,bee;
int dfs(vector<vector<int> > grap,int st, int depth)
{
    visited[st]=1;
    if(depth==1)r=st;
    if(st==bee)z=r;
    int i;
    for(i=0;i<grap[st].size();i++){
            if(visited[grap[st][i]]==0)
            {
        subtree[st]+=dfs(grap,grap[st][i],depth+1);
        }}
    if(i==0)
        return subtree[st]=1;
    else
        return subtree[st];
}
int main()
{
    z=r=0;
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,flo; cin>>n>>flo>>bee;
    subtree.assign(n+1,1); subtree[0]=0;
    visited.assign(n+1,0); visited[0]=1;
    vector<vector<int> > grap(n+1);
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
        grap[y].push_back(x);
    }
    dfs(grap,flo,0);
    //cout<<subtree[bee]<<" "<<subtree[flo]<<"\n";
    cout<<n*(n-1)-(subtree[bee])*(subtree[flo]-subtree[z])<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
vector<int> subtree;
int z,r,bee;
void dfs(vector<vector<int> > grap,int st, int depth)
{
    if(depth==1)r=st;
    if(st==bee)z=r;
    for(int i=0;i<grap[st].size();i++){
            dfs(grap,grap[st][i],depth+1);
        subtree[st]+=subtree[grap[st][i]];}
}
int main()
{
    z=r=0;
    int n,flo; cin>>n>>flo>>bee;
    subtree.assign(n+1,1); subtree[0]=0;
    vector<vector<int> > grap(n+1);
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
    }
    dfs(grap,flo,0);
    //cout<<subtree[bee]<<" "<<subtree[flo]<<"\n";
    cout<<n*(n-1)-(subtree[bee])*(subtree[flo]-subtree[z])<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
int count_1, count_2;
int bee;
void dfs(vector<vector<int> > grap,int st, int flag, int depth)
{
    if(st==bee){flag=1;count_2-=depth-1;}
    if(flag)count_1++;
    else count_2++;
    for(int i=0;i<grap[st].size();i++)
        dfs(grap,grap[st][i],flag,depth+1);
}
int main()
{
    count_1=count_2=0;
    int n,flo; cin>>n>>flo>>bee;
    vector<vector<int> > grap(n+1);
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
    }
    dfs(grap,flo,0,0);
    cout<<n*(n-1)-(count_2)*(count_1)<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
vector<int> subtree;
vector<int> visited;
int z,r,bee;
int dfs(vector<vector<int> > grap,int st, int depth)
{
    visited[st]=1;
    if(depth==1)r=st;
    if(st==bee)z=r;
    int i;
    for(i=0;i<grap[st].size();i++){
            if(visited[grap[st][i]]==0)
            {
        subtree[st]+=dfs(grap,grap[st][i],depth+1);
        }}
    if(i==0)
        return subtree[st]=1;
    else
        return subtree[st];
}
int main()
{
    z=r=0;
    int n,flo; cin>>n>>flo>>bee;
    subtree.assign(n+1,1); subtree[0]=0;
    visited.assign(n+1,0); visited[0]=1;
    vector<vector<int> > grap(n+1);
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
        grap[y].push_back(x);
    }
    dfs(grap,flo,0);
    //cout<<subtree[bee]<<" "<<subtree[flo]<<"\n";
    cout<<n*(n-1)-(subtree[bee])*(subtree[flo]-subtree[z])<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
vector<int> subtree;
vector<int> parent;
int flag;
int count_;
void dfs(vector<vector<int> > grap,int st)
{
    for(int i=0;i<grap[st].size();i++)
        {
            dfs(grap,grap[st][i]);
            parent[grap[st][i]]=st;
        }
    for(int i=0;i<grap[st].size();i++)
        subtree[st]+=subtree[grap[st][i]];
}
int par(int flo, int x)
{
    while(parent[x]!=flo)
        x=parent[x];
    return x;
}
int main()
{
    flag=count_=0;
    int n,flo,bee; cin>>n>>flo>>bee;
    subtree.assign(n+1,1);
    parent.assign(n+1,0); subtree[0]=0;
    vector<vector<int> > grap(n+1);
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        grap[x].push_back(y);
    }
    dfs(grap,flo);
    //cout<<subtree[bee]<<" "<<subtree[flo]<<"\n";
    cout<<n*(n-1)-(subtree[bee])*(subtree[flo]-subtree[par(flo,bee)])<<"\n";
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

struct BFS {
  long long u;
  bool fl;
};

vector<long long> g[300005];
bool viz[300005];
long long nodes;

void dfs(long long node, long long dad) {
  nodes++;
  viz[node] = true;
  for (auto u : g[node])
    if (u != dad)
      dfs(u, node);
}

int main() {
  long long n, x, y;
  cin >> n >> x >> y;
  long long root = 0;
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  long long ram = 0;
  for (auto u : g[y]) {
    dfs(u, y);
    if (viz[x]) {
      ram = u;
      break;
    }
  }
  for (int i = 1; i <= n; i++)
    viz[i] = false;
  nodes = 0;
  for (auto u : g[y]) {
    if (u != ram)
      dfs(u, y);
  }
  queue<BFS> q;
  long long ans = (nodes + 1) * nodes / 2;
  root = y;
  q.push({root, false});
  nodes++;
  long long ab = nodes;
  viz[root] = true;
  while (!q.empty()) {
    BFS top = q.front();
    q.pop();
    long long u = top.u;
    for (auto v : g[u]) {
      if (!viz[v]) {
        ans += (1LL * nodes * 2);
        if (top.fl)
          ans -= ab;
        if (v != x)
          q.push({v, top.fl});
        else {
          q.push({v, true});
          ans -= ab;
        }
        nodes++;
        viz[v] = true;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

struct BFS {
  long long u;
  bool fl;
};

vector<long long> g[300005];
bool viz[300005];
long long nodes;

void dfs(long long node, long long dad) {
  nodes++;
  viz[node] = true;
  for (auto u : g[node])
    if (!viz[u])
      dfs(u, node);
}

int main() {
  long long n, x, y;
  cin >> n >> x >> y;
  long long root = 0;
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  long long ram = 0;
  viz[y] = true;
  for (auto u : g[y]) {
    dfs(u, y);
    if (viz[x]) {
      ram = u;
      break;
    }
  }
  for (long long i = 1; i <= n; i++)
    viz[i] = false;
  nodes = 0;
  viz[y] = true;
  for (auto u : g[y]) {
    if (u != ram)
      dfs(u, y);
  }
  queue<BFS> q;
  long long ans = (nodes + 1) * nodes;
  root = y;
  q.push({root, false});
  nodes++;
  long long ab = nodes;
  viz[root] = true;
  while (!q.empty()) {
    BFS top = q.front();
    q.pop();
    long long u = top.u;
    for (auto v : g[u]) {
      if (!viz[v]) {
        ans += (1LL * nodes * 2);
        if (top.fl)
          ans -= ab;
        if (v != x)
          q.push({v, top.fl});
        else {
          q.push({v, true});
          ans -= ab;
        }
        nodes++;
        viz[v] = true;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

struct BFS {
  long long u;
  bool fl;
};

vector<long long> g[300005];
bool viz[300005];
long long nodes;

void dfs(long long node, long long dad) {
  nodes++;
  viz[node] = true;
  for (auto u : g[node])
    if (!viz[u])
      dfs(u, node);
}

int main() {
  long long n, x, y;
  cin >> n >> x >> y;
  long long root = 0;
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  long long ram = 0;
  viz[y] = true;
  for (auto u : g[y]) {
    dfs(u, y);
    if (viz[x]) {
      ram = u;
      break;
    }
  }
  for (long long i = 1; i <= n; i++)
    viz[i] = false;
  nodes = 0;
  viz[y] = true;
  for (auto u : g[y]) {
    if (u != ram)
      dfs(u, y);
  }
  queue<BFS> q;
  long long ans = (nodes + 1) * nodes / 2;
  root = y;
  q.push({root, false});
  nodes++;
  long long ab = nodes - 1;
  viz[root] = true;
  while (!q.empty()) {
    BFS top = q.front();
    q.pop();
    long long u = top.u;
    for (auto v : g[u]) {
      if (!viz[v]) {
        ans += (1LL * nodes * 2);
        if (top.fl)
          ans -= ab;
        if (v != x)
          q.push({v, top.fl});
        else {
          q.push({v, true});
          ans -= ab;
        }
        nodes++;
        viz[v] = true;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

struct BFS {
  int u;
  bool fl;
  bool bees;
  int length;
};

vector<int> g[300005];
bool viz[300005];

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  int root = 0;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  queue<BFS> q;
  long long ans = -1;
  root = y;
  q.push({root, false, false, 1});
  viz[root] = true;
  while (!q.empty()) {
    BFS top = q.front();
    q.pop();
    int u = top.u;
    for (auto v : g[u]) {
      if (!viz[v]) {
        if (top.fl == false)
          ans += (1LL * top.length * 2);
        else
          ans += (1LL * (top.length - 1) + 1LL * top.length);
        if (v != x)
          q.push({v, top.fl, false, top.length + 1});
        else if (v == x)
          q.push({v, true, false, top.length + 1});
        viz[v] = true;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

struct BFS {
  long long u;
  bool fl;
};

vector<long long> g[300005];
bool viz[300005];
long long nodes;

void dfs(long long node, long long dad) {
  nodes++;
  viz[node] = true;
  for (auto u : g[node])
    if (!viz[u])
      dfs(u, node);
}

int main() {
  long long n, x, y;
  cin >> n >> x >> y;
  long long root = 0;
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  long long ram = 0;
  viz[y] = true;
  for (auto u : g[y]) {
    dfs(u, y);
    if (viz[x]) {
      ram = u;
      break;
    }
  }
  for (long long i = 1; i <= n; i++)
    viz[i] = false;
  nodes = 0;
  viz[y] = true;
  for (auto u : g[y]) {
    if (u != ram)
      dfs(u, y);
  }
  queue<BFS> q;
  long long ans = (nodes + 1) * nodes / 2;
  root = y;
  q.push({root, false});
  nodes++;
  long long ab = nodes;
  viz[root] = true;
  while (!q.empty()) {
    BFS top = q.front();
    q.pop();
    long long u = top.u;
    for (auto v : g[u]) {
      if (!viz[v]) {
        ans += (1LL * nodes * 2);
        if (top.fl)
          ans -= ab;
        if (v != x)
          q.push({v, top.fl});
        else {
          q.push({v, true});
          ans -= ab;
        }
        nodes++;
        viz[v] = true;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


#include<iostream>
using namespace std;
int main()
{
    cout << 500 << endl;
    cout << 1 << " " << 1000000 << endl;
    for (int i = 2;i<=499;i++) cout << i << " " << 1 << endl;
    cout << 500 << " " << 1000000 << endl;
}


#include <algorithm>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

const int MAXN = 500;

const int n = 310;
double r[MAXN];

int main() {
	printf("%d\n", n);
	puts("0 1000000");
	int x = 44000;
	r[0] = 1000000;
	for (int i = 1; i < 309; i++) {
		int nxtx;
		if (i == 1) {
			nxtx = x + 484 * 2 - 1;
			r[i] = (double)x * x / 4 / r[i - 1];
		} else {
			nxtx = x + r[i - 1] * 2 - 1;
			r[i] = (double)(nxtx - x) * (nxtx - x) / 4 / r[i - 1];
		}
		printf("%d 484\n", x);
		x = nxtx;
	}
	puts("1000000 1000000");
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
	puts("500");
	puts("0 1000000");
	for (int i = 1; i < 499; i++) {
		printf("%d 1\n", i);
	}
	puts("499 1000000");
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
	puts("301");
	puts("0 1000000");
	int x = 44000;
	for (int i = 1; i < 300; i++) {
		printf("%d 484\n", x);
		x += 484 * 2 - i;
	}
	puts("500000 1000000");
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
	puts("500");
	puts("0 1000000");
	int x = 0;
	for (int i = 1; i < 499; i++) {
		x += 500 - i;
		printf("%d 500\n", x);
	}
	x += 200000;
	printf("500000 1000000\n", x);
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

const int MAXN = 500;

const int n = 310;
double r[MAXN];

int main() {
	printf("%d\n", n);
	puts("0 1000000");
	int x = 44000;
	r[0] = 1000000;
	for (int i = 1; i < 310; i++) {
		int nxtx;
		if (i == 1) {
			nxtx = x + 484 * 2 - 1;
			r[i] = (double)x * x / 4 / r[i - 1];
		} else {
			nxtx = x + r[i - 1] * 2 - 1;
			r[i] = (double)(nxtx - x) * (nxtx - x) / 4 / r[i - 1];
		}
		printf("%d 484\n", x);
		x = nxtx;
	}
	puts("1000000 1000000");
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

const int MAXN = 500;

const int n = 310;
double r[MAXN];

int main() {
	printf("%d\n", n);
	puts("0 1000000");
	int R = 480;
	int x = 2000 * sqrt(R) - 1;
	r[0] = 1000000;
	for (int i = 1; i < n - 1; i++) {
		int nxtx;
		if (i == 1) {
			nxtx = x + R * 2 - 1;
			r[i] = (double)x * x / 4 / r[i - 1];
		} else {
			nxtx = x + r[i - 1] * 2 - 1;
			r[i] = (double)(nxtx - x) * (nxtx - x) / 4 / r[i - 1];
		}
		printf("%d %d\n", x, R);
//		printf("%d %d (%lf)\n", x, R, r[i]);
		x = nxtx;
	}
//	printf("1000000 1000000 (%lf)\n", (1000000.0 - x) * (1000000 - x) / 4 / r[0]);
//	printf("1000000 1000000 (%lf)\n", (1000000.0 - x) * (1000000 - x) / 4 / r[1]);
//	printf("1000000 1000000 (%lf)\n", (1000000.0 - x) * (1000000 - x) / 4 / r[n - 2]);
	puts("1000000 1000000");
	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	cout << 500 << endl;
	cout << 0 << ' ' << 1000000 << endl;
	for (int i = 1; i < 500; i++)
		cout << i << ' ' << 1 << endl;
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

set <int > S;
int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	cout << 1 << endl;
	cout << "1 1000000\n";
	/*
	srand(time(0));
	int n = rand() % 500;
	n++;
	cout << n << endl;
	while (S.size() < n)
		S.insert(rand() % 1000000);
	for (set <int> :: iterator it = S.begin(); it != S.end(); it++)
		cout << *it << ' ' << rand() % 1000000 + 1 << endl;*/
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

set <int > S;
int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	cout << 2 << endl;
	cout << "0 1\n";
	cout << "2 2\n";
	/*
	srand(time(0));
	int n = rand() % 500;
	n++;
	cout << n << endl;
	while (S.size() < n)
		S.insert(rand() % 1000000);
	for (set <int> :: iterator it = S.begin(); it != S.end(); it++)
		cout << *it << ' ' << rand() % 1000000 + 1 << endl;*/
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

set <int > S;
int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	cout << 2 << endl;
	cout << "1 100000\n";
	cout << "2 1000000\n";
	/*
	srand(time(0));
	int n = rand() % 500;
	n++;
	cout << n << endl;
	while (S.size() < n)
		S.insert(rand() % 1000000);
	for (set <int> :: iterator it = S.begin(); it != S.end(); it++)
		cout << *it << ' ' << rand() % 1000000 + 1 << endl;*/
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

int main()
{
//	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	cout << 302 << endl;
	cout << "0 1000000\n";
	int curx = 360000, cury = 300;
	while (cury) {
		cout << curx << ' ' << cury << endl;
		cury--;
		curx += 600;
	}
	cout << 1000000 << ' ' << 1000000 << endl;
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

set <int > S;
int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	cout << "1\n2 2\n";
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;

set <int > S;
int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	srand(time(NULL));
	int n = rand() % 500;
	n++;
	cout << n << endl;
	while (S.size() < n)
		S.insert(rand() % 1000000);
	for (set <int> :: iterator it = S.begin(); it != S.end(); it++)
		cout << *it << ' ' << rand() % 1000000 + 1 << endl;
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

set <int > S;
int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	srand(time(NULL));
	int n = rand() % 500;
	n++;
	cout << n << endl;
	while (S.size() < n)
		S.insert(rand() % 1000000);
	for (set <int> :: iterator it = S.begin(); it != S.end(); it++)
		cout << *it << ' ' << rand() % 1000000 + 1 << endl;
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	cout << 500 << endl;
	for (int i = 1; i < 500; i++)
		cout << i << ' ' << 1 << endl;

	cout << 0 << ' ' << 1000000 << endl;
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

set <int > S;
int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(4);
	srand(time(NULL));
	int n = rand() % 500;
	n++;
	cout << n << endl;
	while (S.size() < n)
		S.insert(rand() % 1000000);
	for (set <int> :: iterator it = S.begin(); it != S.end(); it++)
		cout << *it << ' ' << rand() % 1000000 + 1 << endl;
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	cout << 3 << endl;
	cout << 0 << ' ' << 3 << endl;
	cout << 2 << ' ' << 3 << endl;
	cout << 4 << ' ' << 3 << endl;
	//for (int i = 1; i < 500; i++)
		//cout << i << ' ' << 1 << endl;
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	cout << 3 << endl;
	cout << 0 << ' ' << 3 << endl;
	cout << 4 << ' ' << 2 << endl;
	cout << 8 << ' ' << 2 << endl;
	//for (int i = 1; i < 500; i++)
		//cout << i << ' ' << 1 << endl;
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

set <int > S;
int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	cout << 2 << endl;
	cout << "1 1000000\n";
	cout << "2 100000\n";
	/*
	srand(time(0));
	int n = rand() % 500;
	n++;
	cout << n << endl;
	while (S.size() < n)
		S.insert(rand() % 1000000);
	for (set <int> :: iterator it = S.begin(); it != S.end(); it++)
		cout << *it << ' ' << rand() % 1000000 + 1 << endl;*/
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

set <int > S;
int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(3);
	srand(time(NULL));
	int n = rand() % 500;
	n++;
	cout << n << endl;
	while (S.size() < n)
		S.insert(rand() % 1000000);
	for (set <int> :: iterator it = S.begin(); it != S.end(); it++)
		cout << *it << ' ' << rand() % 1000000 + 1 << endl;
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

set <int > S;
int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	cout << 2 << endl;
	cout << "0 2\n";
	cout << "2 1\n";
	/*
	srand(time(0));
	int n = rand() % 500;
	n++;
	cout << n << endl;
	while (S.size() < n)
		S.insert(rand() % 1000000);
	for (set <int> :: iterator it = S.begin(); it != S.end(); it++)
		cout << *it << ' ' << rand() % 1000000 + 1 << endl;*/
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+10;

set <int > S;
int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	cout << 302 << endl;
	cout << "0 1000000\n";
	int curx = 10000, cury = 300;
	while (cury) {
		cout << curx << ' ' << cury << endl;
		cury--;
		curx += 1000;
	}
	cout << 1000000 << ' ' << 600000 << endl;
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874
#define x1 x95874
#define x0 x952874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int MAXN = (int)1e3+5;
const int INF = (int)1e9+10;
const int N = 100;
const int M = (int)1e5;

class mirror {
public:
	int point, x1, x2;
	bool used;
	mirror () {}
};

class line {
public:
	ld k, b;
	line () {}
	line(ld x1, ld y1, ld x2, ld y2) {
		k = (y2 - y1) / (x2 - x1);
		b = (y1 - k * x1);
	}
};

inline ld getx(ld y, line L) {
	return (y - L.b) / L.k;
}

mirror up[MAXN], down[MAXN], nup[MAXN];

int n, h1, h2, n1, n2, maxans = 0;

inline void Cclear() {
	for (int i = 0; i < n1; i++)
		up[i].used = 0;
	for (int i = 0; i < n2; i++)
		down[i].used = 0;
	return;
}

inline bool ok1(ld x, int &ind) {
	for (int i = 0; i < n2; i++)
		if (x >= down[i].x1 && x <= down[i].x2) {
			ind = i;
			return true;
		}
	return false;
}

inline bool ok2(ld x, int &ind) {
	for (int i = 0; i < n1; i++)
		if (x >= up[i].x1 && x <= up[i].x2) {
			ind = i;
			return true;
		}
	return false;
}
int main()
{
	//freopen("", "r", stdin);
	//freopen("", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(5);
	cin >> h1 >> h2 >> n;
	for (int i = 0; i < n; i++) {
		int p, x1, x2;
		char c;
		cin >> p >> c >> x1 >> x2;
		if (c == 'T') {
			up[n1].point = p;
			up[n1].x1 = x1;
			up[n1].x2 = x2;
			n1++;
		} else {
			down[n2].point = p;
			down[n2].x1 = x1;
			down[n2].x2 = x2;
			n2++;
		}
	}
	ld x1 = 0, y1 = h1, x2 = M, y2 = h2;
	for (int kol = 1; kol < 110; kol++) {
		Cclear();
		int curans = 0, good = 1;
		if (kol % 2)
			y2 = -(kol - 1) * N - h2;
		else
			y2 = -(kol - 1) * N - (N - h2);
		//cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;
		//cout << "kol = " << kol << " : " << y2 << endl;
		line L = line(x1, y1, x2, y2);
		//cout << "Line = " << L.k << ' ' << L.b << endl;
		for (int cy = 0; cy < kol; cy++) {
			ld cury = (ld)cy * -100.0;
			//cout <<"cury = " << cury << " : " << getx(cury, L) << endl;
			if (cy % 2 == 0) {
				int ind;
				bool f = ok1(getx(cury, L), ind);//down
				//cout << "F = " << f << endl;
				//if (f) cout << "IND = " << ind << endl;
				if (f && !down[ind].used) {
					curans += down[ind].point;
					//cout << "CURANS = " << curans << endl;
					down[ind].used = 1;
				} else {
					good = 0;
					break;
				}
			} else {
				int ind;
				bool f = ok2(getx(cury, L), ind);//up
				if (f && !up[ind].used)  {
					curans += up[ind].point;
					up[ind].used = 1;
				} else {
					good = 0;
					break;
				}
			}
		}
		if (good)
			maxans = max(maxans, curans);
	}
	/*int nn = n1;
	n1 = n2;
	for (int i = 0; i < nn; i++)
		nup[i] = up[i];
	for (int i = 0; i < n1; i++)
		up[i] = down[i];
	n2 = nn;
	for (int i = 0; i < n2; i++)
		down[i] = nup[i];*/
	for (int kol = 1; kol < 110; kol++) {
		Cclear();
		int curans = 0, good = 1;
		if (kol % 2)
			y2 = kol * N + N - h2;
		else
			y2 = kol * N + h2;
		//cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;
		//cout << "kol = " << kol << " : " << y2 << endl;
		line L = line(x1, y1, x2, y2);
		//cout << "Line = " << L.k << ' ' << L.b << endl;
		for (int cy = 0; cy < kol; cy++) {
			ld cury = (ld)cy * 100.0;
			//cout <<"cury = " << cury << " : " << getx(cury, L) << endl;
			if (cy % 2 == 0) {
				int ind;
				bool f = ok1(getx(cury, L), ind);//down
				//cout << "F = " << f << endl;
				//if (f) cout << "IND = " << ind << endl;
				if (f && !down[ind].used) {
					curans += down[ind].point;
					//cout << "CURANS = " << curans << endl;
					down[ind].used = 1;
				} else {
					good = 0;
					break;
				}
			} else {
				int ind;
				bool f = ok2(getx(cury, L), ind);//up
				if (f && !up[ind].used)  {
					curans += up[ind].point;
					up[ind].used = 1;
				} else {
					good = 0;
					break;
				}
			}
		}
		if (good)
			maxans = max(maxans, curans);
	}
	cout << maxans;
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public:
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y0 y32479
#define y1 y95874

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ld pi = 3.1415926535897932384626433832795;
const ld eps = 1e-9;
const int N = (int)1e5+5;
const int INF = (int)1e9+110;

set <int > S;
int main()
{
	//freopen("", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
    cout.flags(ios::fixed);
    cout.precision(2);
	srand(time(NULL));
	int n = rand() % 500;
	n++;
	cout << n << endl;
	while (S.size() < n)
		S.insert(rand() % 1000000);
	for (set <int> :: iterator it = S.begin(); it != S.end(); it++)
		cout << *it << ' ' << rand() % 1000000 + 1 << endl;
    return 0;
}