#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const double pi = acos(-1.0);
const int size = 200 * 1000 + 100;

int ban;
int ans = 0;
int deep[size];
vector <int> vertex[size];
bool good[size];
int deepest[size];

void dfs_deep(int v, int fr, int d) {
	deep[v] = d;  
	deepest[v] = 0;
	good[v] = (v == ban);
	for (int i = 0; i < (int) vertex[v].size(); i++)
		if (vertex[v][i] != fr) {
			dfs_deep(vertex[v][i], v, d + 1);
			deepest[v] = max(deepest[v], deepest[vertex[v][i]] + 1);
			good[v] = good[v] || good[vertex[v][i]];
		}
	if (fr == -1)
		good[v] = false;	 
}

void dfs_ans(int v, int fr, int d) {
	int loc_d = 0;
	for (int i = 0; i < (int) vertex[v].size(); i++)
		if (vertex[v][i] != fr && !good[vertex[v][i]])
			loc_d = max(loc_d, deepest[vertex[v][i]] + 1);
	if (good[v])
		ans = max(ans, min(d, loc_d + deep[ban] - deep[v]));
	for (int i = 0; i < (int) vertex[v].size(); i++)
		if (vertex[v][i] != fr && good[vertex[v][i]])
			dfs_ans(vertex[v][i], v, max(d, loc_d + deep[v])); 
}

int n;

int main() {
    freopen("dwarfs.in", "r", stdin);
    freopen("dwarfs.out", "w", stdout);

    scanf("%d", &n);
    int v, u;
    for (int i = 0; i < n - 1; i++) {
    	scanf("%d%d", &v, &u);
    	v--, u--;
    	vertex[v].pb(u);
    	vertex[u].pb(v);
    }

    scanf("%d%d", &v, &u);
    v--, u--;
    ban = u;
    dfs_deep(v, -1, 0);
    dfs_ans(v, -1, 0);

    cout << ans + 1 << endl;

    return 0;
}