#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main(){
    int N;
    int M;
    int Q;
    cin >> N >> M >> Q;
    int l;
    int r;
    vector<vector<int>> x(N, vector<int>(N, 0));
    vector<vector<int>> c(N, vector<int>(N, 0));
    vector<int> p(Q);
    vector<int> q(Q);
    int tmp_p;
    int tmp_q;
    for(int i=0; i<M; i++){
        cin >> l >> r;
        l--;
        r--;
        x[l][r]++;
    }
    for(int i=0; i<Q; i++){
        cin >> tmp_p >> tmp_q;
        tmp_p--;
        tmp_q--;
        p[i]=tmp_p;
        q[i]=tmp_q;
    }
    for(int i=0; i<N; i++){
        for(int j=i; j<N; j++){
            c[i][j]+=x[i][j];
            if(j!=i){
                c[i][j]+=c[i][j-1];
            }
        }
    }

    for(int i=0; i<Q; i++){
        int ans=0;
        for(int j=p[i]; j<=q[i]; j++){
            ans+=c[j][q[i]];
        }
        cout << ans << endl;
    }

    return 0;
}

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;
// typedef long long int 
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
// typedef pair<ll,ll> pll;
const int modi = 1e9+7;
const int mxn = 1e5+10;
vi adj[mxn];

void dfs(int u ,int p, int* dis, int d = 0){
	dis[u] = d;
	for(auto v:adj[u]){
		if(v==p)continue;

		dfs(v,u,dis,d+1);
	}
}

void solve(){
	int n;
	cin >> n;
	int t,a; // t is going away a is coming near
	cin >> t >> a;
	--t,--a;
	for(int i =0;i<n-1;i++){
		int u ,v;
		cin >> u >> v;
		--u,--v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	vector<int> leaves;
	for(int i =0;i<n;i++)
	{
		if(adj[i].size()==1){
			leaves.pb(i);
		}
	}

	int dt[n],da[n];
	dfs(t,-1,dt);
	dfs(a,-1,da);
	int ans =0;
	for(auto e:leaves){
		// cout << e << " " << endl;
		if(dt[e]>da[e])
			continue;
		ans = max(ans,da[e]-1);
	}
	cout << ans << endl;
 }
int main(){
	fast;
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif

	// int t;cin >> t;while(t--)
		solve();
}
