/*Author: Satyajeet Singh, Delhi Technological University*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;

public class Main {
/*********************************************Constants******************************************/
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static long mod=(long)1e9+7;
    static long mod1=998244353;
    static boolean sieve[];
    static ArrayList<Integer> primes;
    static ArrayList<Long> factorial;
    static HashSet<Integer> graph[];
/****************************************Solutions Begins*****************************************/
    static boolean vis[];
    static int parent[];
    static int dfs2(int start){
        vis[start]=true;
        int ans=0;
        for(int u:graph[start]){
            if(!vis[u])
            ans=Math.max(ans,dfs2(u));
        }
        return ans+1;
    }
    static void dfs1(int start,int par,int dist[]){
        parent[start]=par;
        dist[start]=dist[par]+1;
        vis[start]=true;
        for(int u:graph[start]){
            if(!vis[u]){
                dfs1(u,start,dist);
            }
        }
    }
    public static void main (String[] args) throws Exception {
        String st[]=br.readLine().split(" ");
        int n=Integer.parseInt(st[0]);
        int x=Integer.parseInt(st[1]);
        Makegraph(n+1);
        for(int i=0;i<n-1;i++){
            st=br.readLine().split(" ");
            int a=Integer.parseInt(st[0]);
            int b=Integer.parseInt(st[1]);
            addEdge(a,b);
            addEdge(b,a);
        }
        int a=x;
        int dist[]=new int[n+1];
        vis=new boolean[n+1];
        parent=new int[n+1];

        dfs1(1,0,dist);
        ArrayList<Integer> path=new ArrayList<>();
        while(a!=0){
            path.add(a);
            a=parent[a];
        }
        Collections.reverse(path);
        int point=path.get(path.size()/2);
        int p1=dist[point];
        vis=new boolean[n+1];
        int max=dfs2(point);
     //   debug(point,max);

      //  debug(path);
        out.println(2*(p1+max-2));

/****************************************Solutions Ends**************************************************/
        out.flush();
        out.close();
    }
/****************************************Template Begins************************************************/
/***************************************Precision Printing**********************************************/
    static void printPrecision(double d){
        DecimalFormat ft = new DecimalFormat("0.00000000000000000");
        out.println(ft.format(d));
    }
/******************************************Graph*********************************************************/
    static void Makegraph(int n){
        graph=new HashSet[n];
        for(int i=0;i<n;i++){
            graph[i]=new HashSet<>();
        }
    }
    static void addEdge(int a,int b){
        graph[a].add(b);
    }

/*********************************************PAIR********************************************************/
    static class PairComp implements Comparator<Pair>{
        public int compare(Pair p1,Pair p2){
            if(p1.u>p2.u){
                return 1;
            }
            else if(p1.u<p2.u){
                return -1;
            }
            else{
                return p1.v-p2.v;
            }
        }
    }
    static class Pair implements Comparable<Pair> {
        int u;
        int v;
        int index=-1;
        public Pair(int u, int v) {
            this.u = u;
            this.v = v;
        }

        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return 31 * hu + hv;
        }

        public boolean equals(Object o) {
            Pair other = (Pair) o;
            return u == other.u && v == other.v;
        }

        public int compareTo(Pair other) {
            if(index!=other.index)
                return Long.compare(index, other.index);
            return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
        }

        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }
    }

    static class PairCompL implements Comparator<Pairl>{
        public int compare(Pairl p1,Pairl p2){
            if(p1.u>p2.u){
                return 1;
            }
            else if(p1.u<p2.u){
                return -1;
            }
            else{
                return 0;
            }
        }
    }
    static class Pairl implements Comparable<Pair> {
            long u;
            long v;
            int index=-1;
            public Pairl(long u, long v) {
                this.u = u;
                this.v = v;
            }

            public int hashCode() {
                int hu = (int) (u ^ (u >>> 32));
                int hv = (int) (v ^ (v >>> 32));
                return 31 * hu + hv;
            }

            public boolean equals(Object o) {
                Pair other = (Pair) o;
                return u == other.u && v == other.v;
            }

            public int compareTo(Pair other) {
                if(index!=other.index)
                    return Long.compare(index, other.index);
                return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
            }

            public String toString() {
                return "[u=" + u + ", v=" + v + "]";
            }
        }
/*****************************************DEBUG***********************************************************/
    public static void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
/************************************MODULAR EXPONENTIATION***********************************************/
    static long modulo(long a,long b,long c) {
        long x=1;
        long y=a;
        while(b > 0){
            if(b%2 == 1){
                x=(x*y)%c;
            }
            y = (y*y)%c; // squaring the base
            b /= 2;
        }
        return  x%c;
    }
/********************************************GCD**********************************************************/
    static long gcd(long x, long y)
    {
        if(x==0)
            return y;
        if(y==0)
            return x;
        long r=0, a, b;
        a = (x > y) ? x : y; // a is greater number
        b = (x < y) ? x : y; // b is smaller number
        r = b;
        while(a % b != 0)
        {
            r = a % b;
            a = b;
            b = r;
        }
        return r;
    }
/******************************************SIEVE**********************************************************/
    static void sieveMake(int n){
        sieve=new boolean[n];
        Arrays.fill(sieve,true);
        sieve[0]=false;
        sieve[1]=false;
        for(int i=2;i*i<n;i++){
            if(sieve[i]){
                for(int j=i*i;j<n;j+=i){
                    sieve[j]=false;
                }
            }
        }
        primes=new ArrayList<Integer>();
        for(int i=0;i<n;i++){
            if(sieve[i]){
                primes.add(i);
            }
        }
    }
/********************************************End***********************************************************/
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt() - 1;
            List<Integer>[] adj = new List[n];
            for (int i = 0; i < n; i++) {
                adj[i] = new ArrayList<>();
            }
            for (int i = 0; i < n - 1; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                adj[a].add(b);
                adj[b].add(a);
            }
            int[] da = bfs(0, adj);
            int[] db = bfs(x, adj);
            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (db[i] <= da[i]) {
                    ans = Math.max(ans, da[i] * 2);
                }
            }
            out.println(ans);
        }

        private int[] bfs(int s, List<Integer>[] adj) {
            int n = adj.length;
            int[] d = new int[n];
            Arrays.fill(d, n + 1);
            d[s] = 0;
            int[] q = new int[n];
            q[0] = s;
            int qt = 0;
            int qh = 1;
            while (qt < qh) {
                int v = q[qt++];
                for (int u : adj[v]) {
                    if (d[u] > 1 + d[v]) {
                        d[u] = 1 + d[v];
                        q[qh++] = u;
                    }
                }
            }
            return d;
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt() - 1;
            List<Integer>[] adj = new List[n];
            for (int i = 0; i < n; i++) {
                adj[i] = new ArrayList<>();
            }
            for (int i = 0; i < n - 1; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                adj[a].add(b);
                adj[b].add(a);
            }
            int[] da = bfs(0, adj);
            int[] db = bfs(x, adj);
            boolean[] reachable = new boolean[n];
            dfs(x, adj, da, db, reachable);
            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (reachable[i]) {
                    ans = Math.max(ans, da[i] * 2);
                }
            }
            out.println(ans);
        }

        private void dfs(int v, List<Integer>[] adj, int[] da, int[] db, boolean[] reachable) {
            reachable[v] = true;
            if (da[v] == db[v]) {
                return;
            }
            for (int u : adj[v]) {
                if (!reachable[u] && db[u] <= da[u]) {
                    dfs(u, adj, da, db, reachable);
                }
            }
        }

        private int[] bfs(int s, List<Integer>[] adj) {
            int n = adj.length;
            int[] d = new int[n];
            Arrays.fill(d, n + 1);
            d[s] = 0;
            int[] q = new int[n];
            q[0] = s;
            int qt = 0;
            int qh = 1;
            while (qt < qh) {
                int v = q[qt++];
                for (int u : adj[v]) {
                    if (d[u] > 1 + d[v]) {
                        d[u] = 1 + d[v];
                        q[qh++] = u;
                    }
                }
            }
            return d;
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int[] firstEdge;
        int[] edgeNxt;
        int[] edgeDst;
        int numEdges;

        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            firstEdge = new int[n];
            Arrays.fill(firstEdge, -1);
            edgeNxt = new int[2 * (n - 1)];
            edgeDst = new int[2 * (n - 1)];
            numEdges = 0;
            int x = in.nextInt() - 1;
            for (int i = 0; i < n - 1; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                addEdge(a, b);
                addEdge(b, a);
            }
            int[] da = bfs(0);
            int[] db = bfs(x);
            boolean[] reachable = new boolean[n];
            dfs(x, da, db, reachable);
            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (reachable[i]) {
                    ans = Math.max(ans, da[i] * 2);
                }
            }
            out.println(ans);
        }

        private void addEdge(int a, int b) {
            int e = numEdges++;
            edgeNxt[e] = firstEdge[a];
            firstEdge[a] = e;
            edgeDst[e] = b;
        }

        private void dfs(int v, int[] da, int[] db, boolean[] reachable) {
            reachable[v] = true;
            if (da[v] == db[v]) {
                return;
            }
            for (int e = firstEdge[v]; e >= 0; e = edgeNxt[e]) {
                int u = edgeDst[e];
                if (!reachable[u] && db[u] <= da[u]) {
                    dfs(u, da, db, reachable);
                }
            }
        }

        private int[] bfs(int s) {
            int n = firstEdge.length;
            int[] d = new int[n];
            Arrays.fill(d, n + 1);
            d[s] = 0;
            int[] q = new int[n];
            q[0] = s;
            int qt = 0;
            int qh = 1;
            while (qt < qh) {
                int v = q[qt++];
                for (int e = firstEdge[v]; e >= 0; e = edgeNxt[e]) {
                    int u = edgeDst[e];
                    if (d[u] > 1 + d[v]) {
                        d[u] = 1 + d[v];
                        q[qh++] = u;
                    }
                }
            }
            return d;
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.util.*;
import java.io.*;
//import java.text.*;

public class Main{
    final long MOD = (long)1e9+7, IINF = (long)1e19;
    final int MAX = (int)1e6+10, MX = (int)1e7+1, INF = (int)1e9;
//    DecimalFormat df = new DecimalFormat("0.00000000");
//    final double EPS = 1e-8;
    FastReader in;
    PrintWriter out;
    boolean multipleTC = false;

    public static void main(String[] args) throws Exception{new Main().run();};
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        for(int i = 1, t = (multipleTC)?ni():1; i<=t; i++)solve(i);
        out.flush();
        out.close();
    }
    int[] dep, height;
    void solve(int TC){
        int n = ni();int x = ni()-1;
        int[][] g = new int[n][];
        int[][] edge = new int[n-1][2];
        int[] cnt = new int[n];
        for(int i = 0; i< n-1; i++){
            edge[i] = new int[]{ni()-1, ni()-1};
            cnt[edge[i][0]]++;
            cnt[edge[i][1]]++;
        }
        for(int i =0 ;i< n; i++)g[i] = new int[cnt[i]];
        for(int i = 0; i< n-1; i++){
            g[edge[i][0]][--cnt[edge[i][0]]] = edge[i][1];
            g[edge[i][1]][--cnt[edge[i][1]]] = edge[i][0];
        }
        int[] d1 = new int[n], d2 = new int[n];
        dfs1(g,d1,0,-1);
        dfs2(g,d1, d2,0,-1);
        int ans = (d2[x])*2;
        pn(ans);
    }

    void dfs1(int[][] g,int[] d1, int u, int p){
        for(int v:g[u]){
            if(v==p)continue;
            d1[v] = d1[u]+1;
            dfs1(g,d1,v,u);
        }
    }

    void dfs2(int[][] g,int[] d1,int[] d2, int u, int p){
        if(g[u].length==1 && g[u][0] == p){
            d2[u] = d1[u];
            return;
        }
        for(int v:g[u]){
            if(v==p)continue;
            dfs2(g,d1,d2,v,u);
            d2[u] = Math.max(d2[u], d2[v]);
        }
    }

    int[] reverse(int[] a){
        int[] o = new int[a.length];
        for(int i = 0; i< a.length; i++)o[i] = a[a.length-i-1];
        return o;
    }

    int[] sort(int[] a){
        if(a.length==1)return a;
        int mid = a.length/2;
        int[] b = sort(Arrays.copyOfRange(a,0,mid)), c = sort(Arrays.copyOfRange(a,mid,a.length));
        for(int i = 0, j = 0, k = 0; i< a.length; i++){
            if(j<b.length && k<c.length){
                if(b[j]<c[k])a[i] = b[j++];
                else a[i] = c[k++];
            }else if(j<b.length)a[i] = b[j++];
            else a[i] = c[k++];
        }
        return a;
    }

    long[] sort(long[] a){
        if(a.length==1)return a;
        int mid = a.length/2;
        long[] b = sort(Arrays.copyOfRange(a,0,mid)), c = sort(Arrays.copyOfRange(a,mid,a.length));
        for(int i = 0, j = 0, k = 0; i< a.length; i++){
            if(j<b.length && k<c.length){
                if(b[j]<c[k])a[i] = b[j++];
                else a[i] = c[k++];
            }else if(j<b.length)a[i] = b[j++];
            else a[i] = c[k++];
        }
        return a;
    }

    int[] ia(int ind,int n){
        int[] out = new int[ind+n];
        for(int i = 0; i< n; i++)out[ind+i] = ni();
        return out;
    }

    long[] la(int ind, int n){
        long[] out = new long[ind+n];
        for(int i = 0; i< n; i++)out[ind+i] = nl();
        return out;
    }

    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bitcount(long n){return (n==0)?0:(1+bitcount(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.util.*;
import java.io.*;
//import java.text.*;

public class Main{
    final long MOD = (long)1e9+7, IINF = (long)1e19;
    final int MAX = (int)1e6+10, MX = (int)1e7+1, INF = (int)1e9;
//    DecimalFormat df = new DecimalFormat("0.00000000");
//    final double EPS = 1e-8;
    FastReader in;
    PrintWriter out;
    boolean multipleTC = false;

    public static void main(String[] args) throws Exception{new Main().run();};
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        for(int i = 1, t = (multipleTC)?ni():1; i<=t; i++)solve(i);
        out.flush();
        out.close();
    }
    int[] dep, height;
    void solve(int TC){
        int n = ni();int x = ni()-1;
        int[][] g = new int[n][];
        int[][] edge = new int[n-1][2];
        int[] cnt = new int[n];
        for(int i = 0; i< n-1; i++){
            edge[i] = new int[]{ni()-1, ni()-1};
            cnt[edge[i][0]]++;
            cnt[edge[i][1]]++;
        }
        for(int i =0 ;i< n; i++)g[i] = new int[cnt[i]];
        for(int i = 0; i< n-1; i++){
            g[edge[i][0]][--cnt[edge[i][0]]] = edge[i][1];
            g[edge[i][1]][--cnt[edge[i][1]]] = edge[i][0];
        }
        int[] d1 = new int[n], d2 = new int[n];
        dfs(g,d1, d2,0,-1);
        int ans = (d1[x]+d2[x])*2;
        pn(ans);
    }

    void dfs(int[][] g,int[] d1, int[] d2, int u, int p){
        int x = 0;
        for(int v:g[u]){
            if(v==p)continue;
            d1[v] = d1[u]+1;
            dfs(g,d1,d2,v,u);
            x = Math.max(x, d2[v]+1);
        }
        d2[u] = x;
    }

    int[] reverse(int[] a){
        int[] o = new int[a.length];
        for(int i = 0; i< a.length; i++)o[i] = a[a.length-i-1];
        return o;
    }

    int[] sort(int[] a){
        if(a.length==1)return a;
        int mid = a.length/2;
        int[] b = sort(Arrays.copyOfRange(a,0,mid)), c = sort(Arrays.copyOfRange(a,mid,a.length));
        for(int i = 0, j = 0, k = 0; i< a.length; i++){
            if(j<b.length && k<c.length){
                if(b[j]<c[k])a[i] = b[j++];
                else a[i] = c[k++];
            }else if(j<b.length)a[i] = b[j++];
            else a[i] = c[k++];
        }
        return a;
    }

    long[] sort(long[] a){
        if(a.length==1)return a;
        int mid = a.length/2;
        long[] b = sort(Arrays.copyOfRange(a,0,mid)), c = sort(Arrays.copyOfRange(a,mid,a.length));
        for(int i = 0, j = 0, k = 0; i< a.length; i++){
            if(j<b.length && k<c.length){
                if(b[j]<c[k])a[i] = b[j++];
                else a[i] = c[k++];
            }else if(j<b.length)a[i] = b[j++];
            else a[i] = c[k++];
        }
        return a;
    }

    int[] ia(int ind,int n){
        int[] out = new int[ind+n];
        for(int i = 0; i< n; i++)out[ind+i] = ni();
        return out;
    }

    long[] la(int ind, int n){
        long[] out = new long[ind+n];
        for(int i = 0; i< n; i++)out[ind+i] = nl();
        return out;
    }

    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bitcount(long n){return (n==0)?0:(1+bitcount(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.util.*;
import java.io.*;
//import java.text.*;

public class Main{
    final long MOD = (long)1e9+7, IINF = (long)1e19;
    final int MAX = (int)1e6+10, MX = (int)1e7+1, INF = (int)1e9;
//    DecimalFormat df = new DecimalFormat("0.00000000");
//    final double EPS = 1e-8;
    FastReader in;
    PrintWriter out;
    boolean multipleTC = false;

    public static void main(String[] args) throws Exception{new Main().run();};
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        for(int i = 1, t = (multipleTC)?ni():1; i<=t; i++)solve(i);
        out.flush();
        out.close();
    }
    int[] dep, height;
    void solve(int TC){
        int n = ni();int x = ni()-1;
        int[][] g = new int[n][];
        int[][] edge = new int[n-1][2];
        int[] cnt = new int[n];
        for(int i = 0; i< n-1; i++){
            edge[i] = new int[]{ni()-1, ni()-1};
            cnt[edge[i][0]]++;
            cnt[edge[i][1]]++;
        }
        for(int i =0 ;i< n; i++)g[i] = new int[cnt[i]];
        for(int i = 0; i< n-1; i++){
            g[edge[i][0]][--cnt[edge[i][0]]] = edge[i][1];
            g[edge[i][1]][--cnt[edge[i][1]]] = edge[i][0];
        }
        int[] par = new int[n],d1 = new int[n], d2 = new int[n];
        dfs1(g,par,d1,0,-1);
        dfs2(g,d1, d2,0,-1);
        int d = d1[x];
        int t = (d-1)/2;
        while(t>0){
            x = par[x];
            t--;
        }
        int ans = (d2[x])*2;
        pn(ans);
    }

    void dfs1(int[][] g,int[] par,int[] d1, int u, int p){
        par[u] = p;
        for(int v:g[u]){
            if(v==p)continue;
            d1[v] = d1[u]+1;
            dfs1(g,par,d1,v,u);
        }
    }

    void dfs2(int[][] g,int[] d1,int[] d2, int u, int p){
        if(g[u].length==1 && g[u][0] == p){
            d2[u] = d1[u];
            return;
        }
        for(int v:g[u]){
            if(v==p)continue;
            dfs2(g,d1,d2,v,u);
            d2[u] = Math.max(d2[u], d2[v]);
        }
    }

    int[] reverse(int[] a){
        int[] o = new int[a.length];
        for(int i = 0; i< a.length; i++)o[i] = a[a.length-i-1];
        return o;
    }

    int[] sort(int[] a){
        if(a.length==1)return a;
        int mid = a.length/2;
        int[] b = sort(Arrays.copyOfRange(a,0,mid)), c = sort(Arrays.copyOfRange(a,mid,a.length));
        for(int i = 0, j = 0, k = 0; i< a.length; i++){
            if(j<b.length && k<c.length){
                if(b[j]<c[k])a[i] = b[j++];
                else a[i] = c[k++];
            }else if(j<b.length)a[i] = b[j++];
            else a[i] = c[k++];
        }
        return a;
    }

    long[] sort(long[] a){
        if(a.length==1)return a;
        int mid = a.length/2;
        long[] b = sort(Arrays.copyOfRange(a,0,mid)), c = sort(Arrays.copyOfRange(a,mid,a.length));
        for(int i = 0, j = 0, k = 0; i< a.length; i++){
            if(j<b.length && k<c.length){
                if(b[j]<c[k])a[i] = b[j++];
                else a[i] = c[k++];
            }else if(j<b.length)a[i] = b[j++];
            else a[i] = c[k++];
        }
        return a;
    }

    int[] ia(int ind,int n){
        int[] out = new int[ind+n];
        for(int i = 0; i< n; i++)out[ind+i] = ni();
        return out;
    }

    long[] la(int ind, int n){
        long[] out = new long[ind+n];
        for(int i = 0; i< n; i++)out[ind+i] = nl();
        return out;
    }

    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bitcount(long n){return (n==0)?0:(1+bitcount(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.util.*;
import java.io.*;
//import java.text.*;

public class Main{
    final long MOD = (long)1e9+7, IINF = (long)1e19;
    final int MAX = (int)1e6+10, MX = (int)1e7+1, INF = (int)1e9;
//    DecimalFormat df = new DecimalFormat("0.00000000");
//    final double EPS = 1e-8;
    FastReader in;
    PrintWriter out;
    boolean multipleTC = false;

    public static void main(String[] args) throws Exception{new Main().run();};
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        for(int i = 1, t = (multipleTC)?ni():1; i<=t; i++)solve(i);
        out.flush();
        out.close();
    }
    int[] dep, height;
    void solve(int TC){
        int n = ni();int x = ni()-1;
        int[][] g = new int[n][];
        int[][] edge = new int[n-1][2];
        int[] cnt = new int[n];
        for(int i = 0; i< n-1; i++){
            edge[i] = new int[]{ni()-1, ni()-1};
            cnt[edge[i][0]]++;
            cnt[edge[i][1]]++;
        }
        for(int i =0 ;i< n; i++)g[i] = new int[cnt[i]];
        for(int i = 0; i< n-1; i++){
            g[edge[i][0]][--cnt[edge[i][0]]] = edge[i][1];
            g[edge[i][1]][--cnt[edge[i][1]]] = edge[i][0];
        }
        int[] d1 = new int[n], d2 = new int[n];
        dfs1(g,d1,0,-1);
        dfs2(g,d2,0,-1);
        int ans = (d1[x]+d2[x])*2;
        pn(ans);
    }

    void dfs1(int[][] g,int[] d1, int u, int p){
        for(int v:g[u]){
            if(v==p)continue;
            d1[v] = d1[u]+1;
            dfs1(g,d1,v,u);
        }
    }

    void dfs2(int[][] g, int[] d2, int u, int p){
        if(g[u].length == 1 && g[u][0]==p)d2[u] = 0;
        else for(int v:g[u]){
            if(v==p)continue;
            dfs2(g,d2,v,u);
            d2[u] = Math.max(d2[u], d2[v]+1);
        }
    }

    int[] reverse(int[] a){
        int[] o = new int[a.length];
        for(int i = 0; i< a.length; i++)o[i] = a[a.length-i-1];
        return o;
    }

    int[] sort(int[] a){
        if(a.length==1)return a;
        int mid = a.length/2;
        int[] b = sort(Arrays.copyOfRange(a,0,mid)), c = sort(Arrays.copyOfRange(a,mid,a.length));
        for(int i = 0, j = 0, k = 0; i< a.length; i++){
            if(j<b.length && k<c.length){
                if(b[j]<c[k])a[i] = b[j++];
                else a[i] = c[k++];
            }else if(j<b.length)a[i] = b[j++];
            else a[i] = c[k++];
        }
        return a;
    }

    long[] sort(long[] a){
        if(a.length==1)return a;
        int mid = a.length/2;
        long[] b = sort(Arrays.copyOfRange(a,0,mid)), c = sort(Arrays.copyOfRange(a,mid,a.length));
        for(int i = 0, j = 0, k = 0; i< a.length; i++){
            if(j<b.length && k<c.length){
                if(b[j]<c[k])a[i] = b[j++];
                else a[i] = c[k++];
            }else if(j<b.length)a[i] = b[j++];
            else a[i] = c[k++];
        }
        return a;
    }

    int[] ia(int ind,int n){
        int[] out = new int[ind+n];
        for(int i = 0; i< n; i++)out[ind+i] = ni();
        return out;
    }

    long[] la(int ind, int n){
        long[] out = new long[ind+n];
        for(int i = 0; i< n; i++)out[ind+i] = nl();
        return out;
    }

    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bitcount(long n){return (n==0)?0:(1+bitcount(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.*;
import java.math.*;
import java.nio.file.attribute.AclEntry.Builder;
import java.security.KeyStore.Entry;
import java.util.*;

 public class CODEFORCES {
	private InputStream is;
	private PrintWriter out;
	int time = 0, dp[][], DP[], start[], end[], dist[], red[], black[], MOD = (int)(1e9+7), arr[];
	int MAX = 200000, N, K, L;
	ArrayList<Integer>[] amp;
	boolean b[], boo[][];
	Pair prr[], parent[][];
	HashSet<Integer> hs = new HashSet<>();

	public static void main(String[] args) throws Exception {
		new Thread(null, new Runnable() {
		public void run() {
			try {

		//new Main().soln();
		} catch (Exception e) {
				System.out.println(e);
			}
		}
	}, "1", 1 << 26).start();
		new CODEFORCES().soln();
	}
	char ch[][];
	void solve() {
		int n = ni(), x = ni()-1;
		amp = (ArrayList<Integer>[]) new ArrayList[n];
		for(int i = 0; i< n; i++) amp[i] = new ArrayList<>();
		buildGraph(n-1);
		int dist1[] = new int[n];
		int dist2[] = new int[n];
		dist = new int[n];
		bfs(0,dist1,n);
		bfs(x,dist2,n);
		b = new boolean[n];
		dfs(0);
		int fa = 0;
		for(int i = 0; i< n;  i++){
			//System.out.println(i+" "+dist1[i]+" "+dist2[i] +" "+dist[i]);
			if(dist1[i]>=dist2[i]){
				fa = Math.max(fa, 2*(dist1[i]+dist[i]-1));
			}
		}
		System.out.println(fa);
	}
	int dfs(int x){
		b[x] = true;
		int max = 0;
		for(int i : amp[x]){
			if(!b[i]){
				max = Math.max(dfs(i), max);
			}
		}
		return dist[x] = (1+max);
	}
	void bfs(int x, int dist[], int n){
		dist[x] = 0;
		Queue<Integer> q = new LinkedList<>();
		q.add(x);
		boolean b[] = new boolean[n];
		b[x]  = true;
		while(!q.isEmpty()){
			int y = q.poll();
			for(int i : amp[y])
			{
				if(!b[i]){
					dist[i] = dist[y]+1;
					q.add(i);
					b[i] = true;
				}
			}
		}
	}
	void buildGraph(int n){
		for(int i = 0; i<n -1;i++){
			int x = ni() -1, y = ni()- 1;
			amp[x].add(y);
			amp[y].add(x);
		}
	}
	long get(int x){
		long val = 0;
		for(int i = 0; i< N; i++){
			val += Math.abs(x-arr[i]);
			x+=L;
		}
		return val;
	}
	void dfs(int i, int j){
		boo[i][j] = true;
		if(ch[i][j]=='F') return;
		Pair p = new Pair(i,j);
		if(i>0 && ch[i-1][j]!='*' && !boo[i-1][j]){
			parent[i-1][j] = p;
			dfs(i-1,j);
		}
		if(j>0 && ch[i][j-1]!='*' && !boo[i][j-1]){
			parent[i][j-1] = p;
			dfs(i,j-1);
		}
		if(i<N-1 && ch[i+1][j]!='*' && !boo[i+1][j]){
			parent[i+1][j] = p;
			dfs(i+1,j);
		}
		if(j<K-1 && ch[i][j+1]!='*' && !boo[i][j+1]){
			parent[i][j+1] = p;
			dfs(i,j+1);
		}
	}
	int recur(int n){
		//System.out.println(n);
		if(n>=N) return 0;
		if(DP[n]!=-1) return DP[n];
		int ans = 0;
		DP[n] = 0;

		for(int i = n; i<N;i++){
			if(start[arr[i]]>n){
				DP[i] = Math.max((red[end[arr[i]]]^red[start[arr[i]]-1]+recur(end[arr[i]])),DP[i]);
			}
			/*if(start[arr[i]]>i){
				ans = Math.max(ans,(red[end[arr[i]]]^red[start[arr[i]]-1]+recur(end[arr[i]])));
				if(arr[i]==2){
					System.out.println(i);
					System.out.println((red[end[arr[i]]]^red[start[arr[i]]-1])+"*");
					System.out.println(ans);
				}
			}*/
		}
		return DP[n];
	}
	void recur(int n, int k){
		if(k<0) return;
		hs.add(K-k);
		if(n>=0 && dp[n][k]!=-1) return;
		if(n>=0) dp[n][k] = 1;
		for(int i = n+1;i<N;i++){
			recur(i,k-arr[i]);
		}
	}
	long modInverse(long a, long mOD2){
        return  power(a, mOD2-2, mOD2);
	}
	long power(long x, long y, long m)
	{
		if (y == 0)
    return 1;
	long p = power(x, y/2, m) % m;
	p = (p * p) % m;

	return (y%2 == 0)? p : (x * p) % m;
	}
	boolean isPrime(int x){
		for(int i = 2;i*1L*i<=x;i++) if(x%i==0) return false;
		return true;
	}
	public String isPossible(int b[]){
		String ans = "Possible";
		int n = b.length;
		Arrays.sort(b);
		if(n==1) return "Possible";
		if(b[0]==1) return "Impossible";
		if(b[0]>=n) return ans;
		int lcm = 1;
		for(int i : b){
			long gcd = gcd(lcm,i);
			lcm *= (i/gcd);
		}
		int cnt = 0;
		for(int i : b) cnt+=lcm/i;
		if(cnt>lcm) return "Impossible";
		return ans;
	}
	public long gcd(long a, long b){
		if(b==0) return a;
		return gcd(b,a%b);
	}
	void failFn(String str, int arr[]){
		int len = 0;
		arr[0] = 0;
		int i = 1;
		while(i<arr.length){
			if(str.charAt(i)==str.charAt(len)){
				arr[i++] = ++len;
				continue;
			}
			if(len == 0){
				arr[i] = len;
				i++;
				continue;
			}
			if(str.charAt(i)!=str.charAt(len)){
				len = arr[len-1];
			}
		}
	}
	static class ST1{
		int arr[], st[], size;
		ST1(int a[]){
			arr = a.clone();
			size = 10*arr.length;
			st = new int[size];
			build(0,arr.length-1,1);
		}
		void build(int ss, int se, int si){
			if(ss==se){
				st[si] = arr[ss];
				return;
			}
			int mid = (ss+se)/2;
			int val = 2*si;
			build(ss,mid,val); build(mid+1,se,val+1);
			st[si] = Math.min(st[val], st[val+1]);
		}
		int get(int ss, int se, int l, int r, int si){
			if(l>se || r<ss || l>r) return Integer.MAX_VALUE;
			if(l<=ss && r>=se) return st[si];
			int mid = (ss+se)/2;
			int val = 2*si;
			return Math.min(get(ss,mid,l,r,val), get(mid+1,se,l,r,val+1));
		}
	}
	static class ST{
		int arr[],lazy[],n;
		ST(int a){
			n = a;
			arr = new int[10*n];
			lazy = new int[10*n];
		}
		void up(int l,int r,int val){
			update(0,n-1,0,l,r,val);
		}
		void update(int l,int r,int c,int x,int y,int val){
			if(lazy[c]!=0){
				lazy[2*c+1]+=lazy[c];
				lazy[2*c+2]+=lazy[c];
				if(l==r)
					arr[c]+=lazy[c];
				lazy[c] = 0;
			}
			if(l>r||x>y||l>y||x>r)
				return;
			if(x<=l&&y>=r){
				lazy[c]+=val;
				return ;
			}
			int mid = l+r>>1;
			update(l,mid,2*c+1,x,y,val);
			update(mid+1,r,2*c+2,x,y,val);
			arr[c] = Math.max(arr[2*c+1], arr[2*c+2]);
		}
		int an(int ind){
			return ans(0,n-1,0,ind);
		}
		int ans(int l,int r,int c,int ind){
			if(lazy[c]!=0){
				lazy[2*c+1]+=lazy[c];
				lazy[2*c+2]+=lazy[c];
				if(l==r)
					arr[c]+=lazy[c];
				lazy[c] = 0;
			}
			if(l==r)
				return arr[c];
			int mid = l+r>>1;
			if(mid>=ind)
				return ans(l,mid,2*c+1,ind);
			return ans(mid+1,r,2*c+2,ind);
		}
	}
	public static class FenwickTree {

	    int[] array; // 1-indexed array, In this array We save cumulative information to perform efficient range queries and updates

	    public FenwickTree(int size) {
	        array = new int[size + 1];
	    }
	    public int rsq(int ind) {
	        assert ind > 0;
	        int sum = 0;
	        while (ind > 0) {
	            sum += array[ind];
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and decrementing ind by that number
	            ind -= ind & (-ind);
	        }
	        return sum;
	    }
	    public int rsq(int a, int b) {
	        assert b >= a && a > 0 && b > 0;
	        return rsq(b) - rsq(a - 1);
	    }
	    public void update(int ind, int value) {
	        assert ind > 0;
	        while (ind < array.length) {
	            array[ind] += value;
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and incrementing ind by that number
	            ind += ind & (-ind);
	        }
	    }
	    public int size() {
	        return array.length - 1;
	    }
	}
	public static int[] shuffle(int[] a, Random gen){
		for(int i = 0, n = a.length;i < n;i++)
		{
			int ind = gen.nextInt(n-i)+i;
			int d = a[i];
			a[i] = a[ind];
			a[ind] = d;
		}
	return a;
	}

	class Pair implements Comparable<Pair>{
		int u, v;
		Pair(int u, int v){
			this.u = u;
			this.v = v;
		}public int hashCode() {
			return Objects.hash();
		}
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return ((u == other.u && v == other.v) || (v == other.u && u == other.v));
		}
		public int compareTo(Pair other) {
			//return Integer.compare(val, other.val);
			return Long.compare(u, other.u);// != 0 ? (Long.compare(u, other.u)) : (Long.compare(v,other.v));
		}
	}
	long power(long x, long y, int mod){
		long ans = 1;
		while(y>0){
			if(y%2==0){
				x = (x*x)%mod;
				y/=2;
			}
			else{
				ans = (x*ans)%mod;
				y--;
			}
		}
		return ans;
	}
	void soln() {
		is = System.in;
		out = new PrintWriter(System.out);
		long s = System.currentTimeMillis();
		solve();
		//out.close();
		out.flush();
		//tr(System.currentTimeMillis() - s + "ms");
	}

	// To Get Input
	// Some Buffer Methods
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}
	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}
}


import java.io.*;
import java.math.*;
import java.nio.file.attribute.AclEntry.Builder;
import java.security.KeyStore.Entry;
import java.util.*;

  public class CODEFORCES {
	private InputStream is;
	private PrintWriter out;
	int time = 0, dp[][], DP[], start[], end[], dist[], red[], black[], MOD = (int)(1e9+7), arr[];
	int MAX = 200000, N, K, L;
	ArrayList<Integer>[] amp;
	boolean b[], boo[][];
	Pair prr[], parent[][];
	HashSet<Integer> hs = new HashSet<>();

	public static void main(String[] args) throws Exception {
		new Thread(null, new Runnable() {
		public void run() {
			try {

		//new Main().soln();
		} catch (Exception e) {
				System.out.println(e);
			}
		}
	}, "1", 1 << 26).start();
		new CODEFORCES().soln();
	}
	char ch[][];
	void solve() {
		int n = ni(), x = ni()-1;
		amp = (ArrayList<Integer>[]) new ArrayList[n];
		for(int i = 0; i< n; i++) amp[i] = new ArrayList<>();
		buildGraph(n-1);
		int dist1[] = new int[n];
		int dist2[] = new int[n];
		dist = new int[n];
		bfs(0,dist1,n);
		bfs(x,dist2,n);
		b = new boolean[n];
		dfs(0);
		int fa = 0;
		for(int i = 0; i< n;  i++){
			//System.out.println(i+" "+dist1[i]+" "+dist2[i] +" "+dist[i]);
			if(dist2[i]<=dist1[i]){
				fa = Math.max(fa, 2*(dist1[i]+dist[i]-1));
			}
		}
		System.out.println(fa);
	}
	int dfs(int x){
		b[x] = true;
		int max = 0;
		for(int i : amp[x]){
			if(!b[i]){
				max = Math.max(dfs(i), max);
			}
		}
		return dist[x] = (1+max);
	}
	void bfs(int x, int dist[], int n){
		dist[x] = 0;
		Queue<Integer> q = new LinkedList<>();
		q.add(x);
		boolean b[] = new boolean[n];
		b[x]  = true;
		while(!q.isEmpty()){
			int y = q.poll();
			for(int i : amp[y])
			{
				if(!b[i]){
					dist[i] = dist[y]+1;
					q.add(i);
					b[i] = true;
				}
			}
		}
	}
	void buildGraph(int n){
		for(int i = 0; i<n ;i++){
			int x = ni() -1, y = ni()- 1;
			amp[x].add(y);
			amp[y].add(x);
		}
	}
	long get(int x){
		long val = 0;
		for(int i = 0; i< N; i++){
			val += Math.abs(x-arr[i]);
			x+=L;
		}
		return val;
	}
	void dfs(int i, int j){
		boo[i][j] = true;
		if(ch[i][j]=='F') return;
		Pair p = new Pair(i,j);
		if(i>0 && ch[i-1][j]!='*' && !boo[i-1][j]){
			parent[i-1][j] = p;
			dfs(i-1,j);
		}
		if(j>0 && ch[i][j-1]!='*' && !boo[i][j-1]){
			parent[i][j-1] = p;
			dfs(i,j-1);
		}
		if(i<N-1 && ch[i+1][j]!='*' && !boo[i+1][j]){
			parent[i+1][j] = p;
			dfs(i+1,j);
		}
		if(j<K-1 && ch[i][j+1]!='*' && !boo[i][j+1]){
			parent[i][j+1] = p;
			dfs(i,j+1);
		}
	}
	int recur(int n){
		//System.out.println(n);
		if(n>=N) return 0;
		if(DP[n]!=-1) return DP[n];
		int ans = 0;
		DP[n] = 0;

		for(int i = n; i<N;i++){
			if(start[arr[i]]>n){
				DP[i] = Math.max((red[end[arr[i]]]^red[start[arr[i]]-1]+recur(end[arr[i]])),DP[i]);
			}
			/*if(start[arr[i]]>i){
				ans = Math.max(ans,(red[end[arr[i]]]^red[start[arr[i]]-1]+recur(end[arr[i]])));
				if(arr[i]==2){
					System.out.println(i);
					System.out.println((red[end[arr[i]]]^red[start[arr[i]]-1])+"*");
					System.out.println(ans);
				}
			}*/
		}
		return DP[n];
	}
	void recur(int n, int k){
		if(k<0) return;
		hs.add(K-k);
		if(n>=0 && dp[n][k]!=-1) return;
		if(n>=0) dp[n][k] = 1;
		for(int i = n+1;i<N;i++){
			recur(i,k-arr[i]);
		}
	}
	long modInverse(long a, long mOD2){
        return  power(a, mOD2-2, mOD2);
	}
	long power(long x, long y, long m)
	{
		if (y == 0)
    return 1;
	long p = power(x, y/2, m) % m;
	p = (p * p) % m;

	return (y%2 == 0)? p : (x * p) % m;
	}
	boolean isPrime(int x){
		for(int i = 2;i*1L*i<=x;i++) if(x%i==0) return false;
		return true;
	}
	public String isPossible(int b[]){
		String ans = "Possible";
		int n = b.length;
		Arrays.sort(b);
		if(n==1) return "Possible";
		if(b[0]==1) return "Impossible";
		if(b[0]>=n) return ans;
		int lcm = 1;
		for(int i : b){
			long gcd = gcd(lcm,i);
			lcm *= (i/gcd);
		}
		int cnt = 0;
		for(int i : b) cnt+=lcm/i;
		if(cnt>lcm) return "Impossible";
		return ans;
	}
	public long gcd(long a, long b){
		if(b==0) return a;
		return gcd(b,a%b);
	}
	void failFn(String str, int arr[]){
		int len = 0;
		arr[0] = 0;
		int i = 1;
		while(i<arr.length){
			if(str.charAt(i)==str.charAt(len)){
				arr[i++] = ++len;
				continue;
			}
			if(len == 0){
				arr[i] = len;
				i++;
				continue;
			}
			if(str.charAt(i)!=str.charAt(len)){
				len = arr[len-1];
			}
		}
	}
	static class ST1{
		int arr[], st[], size;
		ST1(int a[]){
			arr = a.clone();
			size = 10*arr.length;
			st = new int[size];
			build(0,arr.length-1,1);
		}
		void build(int ss, int se, int si){
			if(ss==se){
				st[si] = arr[ss];
				return;
			}
			int mid = (ss+se)/2;
			int val = 2*si;
			build(ss,mid,val); build(mid+1,se,val+1);
			st[si] = Math.min(st[val], st[val+1]);
		}
		int get(int ss, int se, int l, int r, int si){
			if(l>se || r<ss || l>r) return Integer.MAX_VALUE;
			if(l<=ss && r>=se) return st[si];
			int mid = (ss+se)/2;
			int val = 2*si;
			return Math.min(get(ss,mid,l,r,val), get(mid+1,se,l,r,val+1));
		}
	}
	static class ST{
		int arr[],lazy[],n;
		ST(int a){
			n = a;
			arr = new int[10*n];
			lazy = new int[10*n];
		}
		void up(int l,int r,int val){
			update(0,n-1,0,l,r,val);
		}
		void update(int l,int r,int c,int x,int y,int val){
			if(lazy[c]!=0){
				lazy[2*c+1]+=lazy[c];
				lazy[2*c+2]+=lazy[c];
				if(l==r)
					arr[c]+=lazy[c];
				lazy[c] = 0;
			}
			if(l>r||x>y||l>y||x>r)
				return;
			if(x<=l&&y>=r){
				lazy[c]+=val;
				return ;
			}
			int mid = l+r>>1;
			update(l,mid,2*c+1,x,y,val);
			update(mid+1,r,2*c+2,x,y,val);
			arr[c] = Math.max(arr[2*c+1], arr[2*c+2]);
		}
		int an(int ind){
			return ans(0,n-1,0,ind);
		}
		int ans(int l,int r,int c,int ind){
			if(lazy[c]!=0){
				lazy[2*c+1]+=lazy[c];
				lazy[2*c+2]+=lazy[c];
				if(l==r)
					arr[c]+=lazy[c];
				lazy[c] = 0;
			}
			if(l==r)
				return arr[c];
			int mid = l+r>>1;
			if(mid>=ind)
				return ans(l,mid,2*c+1,ind);
			return ans(mid+1,r,2*c+2,ind);
		}
	}
	public static class FenwickTree {

	    int[] array; // 1-indexed array, In this array We save cumulative information to perform efficient range queries and updates

	    public FenwickTree(int size) {
	        array = new int[size + 1];
	    }
	    public int rsq(int ind) {
	        assert ind > 0;
	        int sum = 0;
	        while (ind > 0) {
	            sum += array[ind];
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and decrementing ind by that number
	            ind -= ind & (-ind);
	        }
	        return sum;
	    }
	    public int rsq(int a, int b) {
	        assert b >= a && a > 0 && b > 0;
	        return rsq(b) - rsq(a - 1);
	    }
	    public void update(int ind, int value) {
	        assert ind > 0;
	        while (ind < array.length) {
	            array[ind] += value;
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and incrementing ind by that number
	            ind += ind & (-ind);
	        }
	    }
	    public int size() {
	        return array.length - 1;
	    }
	}
	public static int[] shuffle(int[] a, Random gen){
		for(int i = 0, n = a.length;i < n;i++)
		{
			int ind = gen.nextInt(n-i)+i;
			int d = a[i];
			a[i] = a[ind];
			a[ind] = d;
		}
	return a;
	}

	class Pair implements Comparable<Pair>{
		int u, v;
		Pair(int u, int v){
			this.u = u;
			this.v = v;
		}public int hashCode() {
			return Objects.hash();
		}
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return ((u == other.u && v == other.v) || (v == other.u && u == other.v));
		}
		public int compareTo(Pair other) {
			//return Integer.compare(val, other.val);
			return Long.compare(u, other.u);// != 0 ? (Long.compare(u, other.u)) : (Long.compare(v,other.v));
		}
	}
	long power(long x, long y, int mod){
		long ans = 1;
		while(y>0){
			if(y%2==0){
				x = (x*x)%mod;
				y/=2;
			}
			else{
				ans = (x*ans)%mod;
				y--;
			}
		}
		return ans;
	}
	void soln() {
		is = System.in;
		out = new PrintWriter(System.out);
		long s = System.currentTimeMillis();
		solve();
		//out.close();
		out.flush();
		//tr(System.currentTimeMillis() - s + "ms");
	}

	// To Get Input
	// Some Buffer Methods
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}
	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}
}


import java.io.*;
import java.math.*;
import java.nio.file.attribute.AclEntry.Builder;
import java.security.KeyStore.Entry;
import java.util.*;

 public class CODEFORCES {
	private InputStream is;
	private PrintWriter out;
	int time = 0, dp[][], DP[], start[], end[], dist[], red[], black[], MOD = (int)(1e9+7), arr[];
	int MAX = 200000, N, K, L;
	ArrayList<Integer>[] amp;
	boolean b[], boo[][];
	Pair prr[], parent[][];
	HashSet<Integer> hs = new HashSet<>();

	public static void main(String[] args) throws Exception {
		new Thread(null, new Runnable() {
		public void run() {
			try {

		//new Main().soln();
		} catch (Exception e) {
				System.out.println(e);
			}
		}
	}, "1", 1 << 26).start();
		new CODEFORCES().soln();
	}
	char ch[][];
	void solve() {
		int n = ni(), x = ni()-1;
		amp = (ArrayList<Integer>[]) new ArrayList[n];
		for(int i = 0; i< n; i++) amp[i] = new ArrayList<>();
		buildGraph(n-1);
		int dist1[] = new int[n];
		int dist2[] = new int[n];
		dist = new int[n];
		bfs(0,dist1,n);
		bfs(x,dist2,n);
		b = new boolean[n];
		dfs(0);
		int fa = 0;
		for(int i = 0; i< n;  i++){
			//System.out.println(i+" "+dist1[i]+" "+dist2[i] +" "+dist[i]);
			if(dist2[i]<dist1[i]){
				fa = Math.max(fa, 2*(dist1[i]+dist[i]-1));
			}
		}
		System.out.println(fa);
	}
	int dfs(int x){
		b[x] = true;
		int max = 0;
		for(int i : amp[x]){
			if(!b[i]){
				max = Math.max(dfs(i), max);
			}
		}
		return dist[x] = (1+max);
	}
	void bfs(int x, int dist[], int n){
		dist[x] = 0;
		Queue<Integer> q = new LinkedList<>();
		q.add(x);
		boolean b[] = new boolean[n];
		b[x]  = true;
		while(!q.isEmpty()){
			int y = q.poll();
			for(int i : amp[y])
			{
				if(!b[i]){
					dist[i] = dist[y]+1;
					q.add(i);
					b[i] = true;
				}
			}
		}
	}
	void buildGraph(int n){
		for(int i = 0; i<n ;i++){
			int x = ni() -1, y = ni()- 1;
			amp[x].add(y);
			amp[y].add(x);
		}
	}
	long get(int x){
		long val = 0;
		for(int i = 0; i< N; i++){
			val += Math.abs(x-arr[i]);
			x+=L;
		}
		return val;
	}
	void dfs(int i, int j){
		boo[i][j] = true;
		if(ch[i][j]=='F') return;
		Pair p = new Pair(i,j);
		if(i>0 && ch[i-1][j]!='*' && !boo[i-1][j]){
			parent[i-1][j] = p;
			dfs(i-1,j);
		}
		if(j>0 && ch[i][j-1]!='*' && !boo[i][j-1]){
			parent[i][j-1] = p;
			dfs(i,j-1);
		}
		if(i<N-1 && ch[i+1][j]!='*' && !boo[i+1][j]){
			parent[i+1][j] = p;
			dfs(i+1,j);
		}
		if(j<K-1 && ch[i][j+1]!='*' && !boo[i][j+1]){
			parent[i][j+1] = p;
			dfs(i,j+1);
		}
	}
	int recur(int n){
		//System.out.println(n);
		if(n>=N) return 0;
		if(DP[n]!=-1) return DP[n];
		int ans = 0;
		DP[n] = 0;

		for(int i = n; i<N;i++){
			if(start[arr[i]]>n){
				DP[i] = Math.max((red[end[arr[i]]]^red[start[arr[i]]-1]+recur(end[arr[i]])),DP[i]);
			}
			/*if(start[arr[i]]>i){
				ans = Math.max(ans,(red[end[arr[i]]]^red[start[arr[i]]-1]+recur(end[arr[i]])));
				if(arr[i]==2){
					System.out.println(i);
					System.out.println((red[end[arr[i]]]^red[start[arr[i]]-1])+"*");
					System.out.println(ans);
				}
			}*/
		}
		return DP[n];
	}
	void recur(int n, int k){
		if(k<0) return;
		hs.add(K-k);
		if(n>=0 && dp[n][k]!=-1) return;
		if(n>=0) dp[n][k] = 1;
		for(int i = n+1;i<N;i++){
			recur(i,k-arr[i]);
		}
	}
	long modInverse(long a, long mOD2){
        return  power(a, mOD2-2, mOD2);
	}
	long power(long x, long y, long m)
	{
		if (y == 0)
    return 1;
	long p = power(x, y/2, m) % m;
	p = (p * p) % m;

	return (y%2 == 0)? p : (x * p) % m;
	}
	boolean isPrime(int x){
		for(int i = 2;i*1L*i<=x;i++) if(x%i==0) return false;
		return true;
	}
	public String isPossible(int b[]){
		String ans = "Possible";
		int n = b.length;
		Arrays.sort(b);
		if(n==1) return "Possible";
		if(b[0]==1) return "Impossible";
		if(b[0]>=n) return ans;
		int lcm = 1;
		for(int i : b){
			long gcd = gcd(lcm,i);
			lcm *= (i/gcd);
		}
		int cnt = 0;
		for(int i : b) cnt+=lcm/i;
		if(cnt>lcm) return "Impossible";
		return ans;
	}
	public long gcd(long a, long b){
		if(b==0) return a;
		return gcd(b,a%b);
	}
	void failFn(String str, int arr[]){
		int len = 0;
		arr[0] = 0;
		int i = 1;
		while(i<arr.length){
			if(str.charAt(i)==str.charAt(len)){
				arr[i++] = ++len;
				continue;
			}
			if(len == 0){
				arr[i] = len;
				i++;
				continue;
			}
			if(str.charAt(i)!=str.charAt(len)){
				len = arr[len-1];
			}
		}
	}
	static class ST1{
		int arr[], st[], size;
		ST1(int a[]){
			arr = a.clone();
			size = 10*arr.length;
			st = new int[size];
			build(0,arr.length-1,1);
		}
		void build(int ss, int se, int si){
			if(ss==se){
				st[si] = arr[ss];
				return;
			}
			int mid = (ss+se)/2;
			int val = 2*si;
			build(ss,mid,val); build(mid+1,se,val+1);
			st[si] = Math.min(st[val], st[val+1]);
		}
		int get(int ss, int se, int l, int r, int si){
			if(l>se || r<ss || l>r) return Integer.MAX_VALUE;
			if(l<=ss && r>=se) return st[si];
			int mid = (ss+se)/2;
			int val = 2*si;
			return Math.min(get(ss,mid,l,r,val), get(mid+1,se,l,r,val+1));
		}
	}
	static class ST{
		int arr[],lazy[],n;
		ST(int a){
			n = a;
			arr = new int[10*n];
			lazy = new int[10*n];
		}
		void up(int l,int r,int val){
			update(0,n-1,0,l,r,val);
		}
		void update(int l,int r,int c,int x,int y,int val){
			if(lazy[c]!=0){
				lazy[2*c+1]+=lazy[c];
				lazy[2*c+2]+=lazy[c];
				if(l==r)
					arr[c]+=lazy[c];
				lazy[c] = 0;
			}
			if(l>r||x>y||l>y||x>r)
				return;
			if(x<=l&&y>=r){
				lazy[c]+=val;
				return ;
			}
			int mid = l+r>>1;
			update(l,mid,2*c+1,x,y,val);
			update(mid+1,r,2*c+2,x,y,val);
			arr[c] = Math.max(arr[2*c+1], arr[2*c+2]);
		}
		int an(int ind){
			return ans(0,n-1,0,ind);
		}
		int ans(int l,int r,int c,int ind){
			if(lazy[c]!=0){
				lazy[2*c+1]+=lazy[c];
				lazy[2*c+2]+=lazy[c];
				if(l==r)
					arr[c]+=lazy[c];
				lazy[c] = 0;
			}
			if(l==r)
				return arr[c];
			int mid = l+r>>1;
			if(mid>=ind)
				return ans(l,mid,2*c+1,ind);
			return ans(mid+1,r,2*c+2,ind);
		}
	}
	public static class FenwickTree {

	    int[] array; // 1-indexed array, In this array We save cumulative information to perform efficient range queries and updates

	    public FenwickTree(int size) {
	        array = new int[size + 1];
	    }
	    public int rsq(int ind) {
	        assert ind > 0;
	        int sum = 0;
	        while (ind > 0) {
	            sum += array[ind];
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and decrementing ind by that number
	            ind -= ind & (-ind);
	        }
	        return sum;
	    }
	    public int rsq(int a, int b) {
	        assert b >= a && a > 0 && b > 0;
	        return rsq(b) - rsq(a - 1);
	    }
	    public void update(int ind, int value) {
	        assert ind > 0;
	        while (ind < array.length) {
	            array[ind] += value;
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and incrementing ind by that number
	            ind += ind & (-ind);
	        }
	    }
	    public int size() {
	        return array.length - 1;
	    }
	}
	public static int[] shuffle(int[] a, Random gen){
		for(int i = 0, n = a.length;i < n;i++)
		{
			int ind = gen.nextInt(n-i)+i;
			int d = a[i];
			a[i] = a[ind];
			a[ind] = d;
		}
	return a;
	}

	class Pair implements Comparable<Pair>{
		int u, v;
		Pair(int u, int v){
			this.u = u;
			this.v = v;
		}public int hashCode() {
			return Objects.hash();
		}
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return ((u == other.u && v == other.v) || (v == other.u && u == other.v));
		}
		public int compareTo(Pair other) {
			//return Integer.compare(val, other.val);
			return Long.compare(u, other.u);// != 0 ? (Long.compare(u, other.u)) : (Long.compare(v,other.v));
		}
	}
	long power(long x, long y, int mod){
		long ans = 1;
		while(y>0){
			if(y%2==0){
				x = (x*x)%mod;
				y/=2;
			}
			else{
				ans = (x*ans)%mod;
				y--;
			}
		}
		return ans;
	}
	void soln() {
		is = System.in;
		out = new PrintWriter(System.out);
		long s = System.currentTimeMillis();
		solve();
		//out.close();
		out.flush();
		//tr(System.currentTimeMillis() - s + "ms");
	}

	// To Get Input
	// Some Buffer Methods
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}
	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}
}


import java.util.PriorityQueue;
import java.util.*;
public class bowwow {

	private static ArrayList<Integer> arr[];
	private static int n;
	private static int x;
	private static int max;
	private static int num;
	private static int mnum;
	private static int count;
	private static int depth[];
	private static int depth2[];
	private static int height[];

	bowwow(int n1,int x1)
	{
		this.n=n1;
		this.x=x1;
		count=0;mnum=0;num=0;
		depth=new int[n+1];
		depth2=new int[n+1];
		height=new int[n+1];
		Arrays.fill(depth, 0);
		Arrays.fill(depth2, 0);
		depth[0]=-1;
		depth2[0]=-1;
		height[0]=0;
		arr=new ArrayList[n+1];
		int i=0;
		for(i=1;i<n+1;i++)
			arr[i]=new ArrayList<Integer>();
	}
	public static void addEdge(int v,int w)
	{
		arr[v].add(w);
		arr[w].add(v);
	}
	public static void dfs(bowwow T,int count,int v)
	{
		height[v]=0;
		depth[v]=count+1;
		for(int b:T.arr[v])
		{
			if(depth[b]==0)
				{
					dfs(T,depth[v],b);
					height[v]=Math.max(height[v], 1+height[b]);
				}
		}

	}
	public static void reach (bowwow T,int num,int x)
	{
		depth2[x]=num+1;
		for(int b:T.arr[x])
		{
			if(depth2[b]==0)
				reach(T,depth2[x],b);
		}
	}
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		x=sc.nextInt();
		int i=0,j=0;
		bowwow obj=new bowwow(n,x);
		for(i=0;i<n-1;i++)
		{
			int p=sc.nextInt();
			int q=sc.nextInt();
			obj.addEdge(p,q);
		}
		obj.reach(obj,0,obj.x);
		obj.dfs(obj, 0, 1);
		max=0;
		for( i=2;i<n+1;i++)
		if(depth2[i]<depth[i])
			max=Math.max(max, depth[i]+height[i]);
		System.out.print((max-1)*2);
	}
}


import java.util.PriorityQueue;
import java.util.*;
public class bowwow {

	private static ArrayList<Integer> arr[];
	private static int n;
	private static int x;
	private static int max;
	private static int num;
	private static int mnum;
	private static int count;
	private static int depth[];
	private static int depth2[];

	bowwow(int n1,int x1)
	{
		this.n=n1;
		this.x=x1;
		count=0;mnum=0;num=0;
		depth=new int[n+1];
		depth2=new int[n+1];
		Arrays.fill(depth, 0);
		Arrays.fill(depth2, 0);

		arr=new ArrayList[n+1];
		int i=0;
		for(i=1;i<n+1;i++)
			arr[i]=new ArrayList<Integer>();
	}
	public static void addEdge(int v,int w)
	{
		arr[v].add(w);
		arr[w].add(v);
	}
	public static void dfs(bowwow T,int count,int v)
	{
		depth[v]=count+1;
		if(depth2[v]<depth[v] && max<depth[v])
			max=depth[v];
		for(int b:T.arr[v])
		{
			if(depth[b]==0)
				dfs(T,depth[v],b);
		}

	}
	public static void reach (bowwow T,int num,int x)
	{
		depth2[x]=num+1;
		for(int b:T.arr[x])
		{
			if(depth2[b]==0)
				reach(T,depth[x],b);
		}

	}

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		x=sc.nextInt();
		int i=0,j=0;
		bowwow obj=new bowwow(n,x);
		for(i=0;i<n-1;i++)
		{
			int p=sc.nextInt();
			int q=sc.nextInt();
			obj.addEdge(p,q);
		}
		obj.reach(obj,0,obj.x);
		obj.dfs(obj, 0, 1);
		System.out.print((max-1)*2);
	}
}


import java.util.PriorityQueue;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
public class bowwow {

	private static ArrayList<Integer> arr[];
	private static int n;
	private static int x;
	private static int max;
	private static int num;
	private static int mnum;
	private static int calls1,calls2;
	private static int count;
	private static int depth[];
	private static int depth2[];
	  static class FastReader
	    {
	        BufferedReader br;
	        StringTokenizer st;

	        public FastReader()
	        {
	            br = new BufferedReader(new
	                     InputStreamReader(System.in));
	        }

	        String next()
	        {
	            while (st == null || !st.hasMoreElements())
	            {
	                try
	                {
	                    st = new StringTokenizer(br.readLine());
	                }
	                catch (IOException  e)
	                {
	                    e.printStackTrace();
	                }
	            }
	            return st.nextToken();
	        }

	        int nextInt()
	        {
	            return Integer.parseInt(next());
	        }

	        long nextLong()
	        {
	            return Long.parseLong(next());
	        }

	        double nextDouble()
	        {
	            return Double.parseDouble(next());
	        }

	        String nextLine()
	        {
	            String str = "";
	            try
	            {
	                str = br.readLine();
	            }
	            catch (IOException e)
	            {
	                e.printStackTrace();
	            }
	            return str;
	        }
	    }

	bowwow(int n1,int x1)
	{
		this.n=n1;
		this.x=x1;
		calls1=0;calls2=0;
		count=0;mnum=0;num=0;
		depth=new int[n+1];
		depth2=new int[n+1];
		Arrays.fill(depth, 0);
		Arrays.fill(depth2, 0);
		depth[0]=-1;
		depth2[0]=-1;
		arr=new ArrayList[n+1];
		int i=0;
		for(i=1;i<n+1;i++)
			arr[i]=new ArrayList<Integer>();
	}
	public static void addEdge(int v,int w)
	{
		arr[v].add(w);
		arr[w].add(v);
	}
	public static void dfs(int count,int v)
	{
		calls1++;
		depth[v]=count+1;
		for(int b:arr[v])
		{
			if(depth[b]==0)
				dfs(depth[v],b);
		}

	}
	public static void reach (int num,int x)
	{
		calls2++;
		depth2[x]=num+1;
		for(int b:arr[x])
		{
			if(depth2[b]==0)
				reach(depth2[x],b);
		}
	}

	public static void main(String args[])
	{
		FastReader sc=new FastReader();
		n=sc.nextInt();
		x=sc.nextInt();
		int i=0,j=0;
		bowwow obj=new bowwow(n,x);
		for(i=0;i<n-1;i++)
		{
			int p=sc.nextInt();
			int q=sc.nextInt();
			obj.addEdge(p,q);
		}
		obj.reach(0,x);
		obj.dfs(0, 1);
		max=0;
		for( i=2;i<n+1;i++)
		if(depth2[i]<depth[i] && max<depth[i] && arr[i].size()==1)
			max=depth[i];
		//System.out.println(calls1+ " "+calls2);
		System.out.print((max-1)*2);
	}
}


import java.util.PriorityQueue;
import java.util.*;
public class bowwow {

	private static ArrayList<Integer> arr[];
	private static int n;
	private static int x;
	private static int max;
	private static int num;
	private static int mnum;
	private static int count;
	private static int depth[];
	private static int depth2[];
	private static int height[];

	bowwow(int n1,int x1)
	{
		this.n=n1;
		this.x=x1;
		count=0;mnum=0;num=0;
		depth=new int[n+1];
		depth2=new int[n+1];
		height=new int[n+1];
		Arrays.fill(depth, 0);
		Arrays.fill(depth2, 0);
		depth[0]=-1;
		depth2[0]=-1;
		height[0]=0;
		arr=new ArrayList[n+1];
		int i=0;
		for(i=1;i<n+1;i++)
			arr[i]=new ArrayList<Integer>();
	}
	public static void addEdge(int v,int w)
	{
		arr[v].add(w);
		arr[w].add(v);
	}
	public static void dfs(int count,int v)
	{
		height[v]=0;
		depth[v]=count+1;
		for(int b:arr[v])
		{
			if(depth[b]==0)
				{
					dfs(depth[v],b);
					height[v]=Math.max(height[v], 1+height[b]);
				}
		}

	}
	public static void reach (int num,int x)
	{
		depth2[x]=num+1;
		for(int b:arr[x])
		{
			if(depth2[b]==0)
				reach(depth2[x],b);
		}
	}
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		x=sc.nextInt();
		int i=0,j=0;
		bowwow obj=new bowwow(n,x);
		for(i=0;i<n-1;i++)
		{
			int p=sc.nextInt();
			int q=sc.nextInt();
			obj.addEdge(p,q);
		}
		obj.reach(0,x);
		obj.dfs( 0, 1);
		max=0;
		for( i=2;i<n+1;i++)
		if(depth2[i]<depth[i])
			max=Math.max(max, depth[i]+height[i]);
		System.out.print((max-1)*2);
	}
}


import java.util.PriorityQueue;
import java.util.*;
public class bowwow {

	private static ArrayList<Integer> arr[];
	private static int n;
	private static int x;
	private static int max;
	private static int num;
	private static int mnum;
	private static int count;
	private static int depth[];
	private static int depth2[];

	bowwow(int n1,int x1)
	{
		this.n=n1;
		this.x=x1;
		count=0;mnum=0;num=0;
		depth=new int[n+1];
		depth2=new int[n+1];
		Arrays.fill(depth, 0);
		Arrays.fill(depth2, 0);

		arr=new ArrayList[n+1];
		int i=0;
		for(i=1;i<n+1;i++)
			arr[i]=new ArrayList<Integer>();
	}
	public static void addEdge(int v,int w)
	{
		arr[v].add(w);
		arr[w].add(v);
	}
	public static void dfs(bowwow T,int count,int v)
	{
		depth[v]=count+1;
		for(int b:T.arr[v])
		{
			if(depth[b]==0)
				dfs(T,depth[v],b);
		}

	}
	public static void reach (bowwow T,int num,int x)
	{
		depth2[x]=num+1;
		for(int b:T.arr[x])
		{
			if(depth2[b]==0)
				reach(T,depth[x],b);
		}
	}

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		x=sc.nextInt();
		int i=0,j=0;
		bowwow obj=new bowwow(n,x);
		for(i=0;i<n-1;i++)
		{
			int p=sc.nextInt();
			int q=sc.nextInt();
			obj.addEdge(p,q);
		}
		obj.reach(obj,0,obj.x);
		obj.dfs(obj, 0, 1);
		max=0;
		for( i=1;i<n+1;i++)
		if(depth2[i]<depth[i] && max<=depth[i] && arr[i].size()==1)
			max=depth[i];
		System.out.print((max-1)*2);
	}
}


import java.util.PriorityQueue;
import java.util.*;
public class bowwow {

	private static ArrayList<Integer> arr[];
	private static int n;
	private static int x;
	private static int max;
	private static int num;
	private static int mnum;
	private static int count;
	private static int depth[];
	private static int depth2[];

	bowwow(int n1,int x1)
	{
		this.n=n1;
		this.x=x1;
		count=0;mnum=0;num=0;
		depth=new int[n+1];
		depth2=new int[n+1];
		Arrays.fill(depth, 0);
		Arrays.fill(depth2, 0);
		depth[0]=-1;
		depth2[0]=-1;
		arr=new ArrayList[n+1];
		int i=0;
		for(i=1;i<n+1;i++)
			arr[i]=new ArrayList<Integer>();
	}
	public static void addEdge(int v,int w)
	{
		arr[v].add(w);
		arr[w].add(v);
	}
	public static void dfs(int count,int v)
	{
		depth[v]=count+1;
		for(int b:arr[v])
		{
			if(depth[b]==0)
				dfs(depth[v],b);
		}

	}
	public static void reach (int num,int x)
	{
		depth2[x]=num+1;
		for(int b:arr[x])
		{
			if(depth2[b]==0)
				reach(depth2[x],b);
		}
	}

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		x=sc.nextInt();
		int i=0,j=0;
		bowwow obj=new bowwow(n,x);
		for(i=0;i<n-1;i++)
		{
			int p=sc.nextInt();
			int q=sc.nextInt();
			obj.addEdge(p,q);
		}
		obj.reach(0,x);
		obj.dfs(0, 1);
		max=0;
		for( i=2;i<n+1;i++)
		if(depth2[i]<depth[i] && max<depth[i] && arr[i].size()==1)
			max=depth[i];
		System.out.print((max-1)*2);
	}
}


import java.util.PriorityQueue;
import java.util.*;
public class bowwow {

	private static ArrayList<Integer> arr[];
	private static int n;
	private static int x;
	private static int max;
	private static int num;
	private static int mnum;
	private static int count;
	private static int depth[];
	private static int depth2[];

	bowwow(int n1,int x1)
	{
		this.n=n1;
		this.x=x1;
		count=0;mnum=0;num=0;
		depth=new int[n+1];
		depth2=new int[n+1];
		Arrays.fill(depth, 0);
		Arrays.fill(depth2, 0);

		arr=new ArrayList[n+1];
		int i=0;
		for(i=1;i<n+1;i++)
			arr[i]=new ArrayList<Integer>();
	}
	public static void addEdge(int v,int w)
	{
		arr[v].add(w);
		arr[w].add(v);
	}
	public static void dfs(bowwow T,int count,int v)
	{
		depth[v]=count+1;
		for(int b:T.arr[v])
		{
			if(depth[b]==0)
				dfs(T,depth[v],b);
		}

	}
	public static void reach (bowwow T,int num,int x)
	{
		depth2[x]=num+1;
		for(int b:T.arr[x])
		{
			if(depth2[b]==0)
				reach(T,depth[x],b);
		}
	}

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		x=sc.nextInt();
		int i=0,j=0;
		bowwow obj=new bowwow(n,x);
		for(i=0;i<n-1;i++)
		{
			int p=sc.nextInt();
			int q=sc.nextInt();
			obj.addEdge(p,q);
		}
		obj.reach(obj,0,obj.x);
		obj.dfs(obj, 0, 1);
		for( i=1;i<n+1;i++)
		if(depth2[i]<depth[i] && max<=depth[i])
			max=depth[i];
		System.out.print((max-1)*2);
	}
}


import java.util.PriorityQueue;
import java.util.*;
public class bowwow {

	private static ArrayList<Integer> arr[];
	private static int n;
	private static int x;
	private static int max;
	private static int num;
	private static int mnum;
	private static int count;
	private static int depth[];
	private static int depth2[];
	private static int height[];

	bowwow(int n1,int x1)
	{
		this.n=n1;
		this.x=x1;
		count=0;mnum=0;num=0;
		depth=new int[n+1];
		depth2=new int[n+1];
		height=new int[n+1];
		Arrays.fill(depth, 0);
		Arrays.fill(depth2, 0);
		depth[0]=-1;
		depth2[0]=-1;
		height[0]=0;
		arr=new ArrayList[n+1];
		int i=0;
		for(i=1;i<n+1;i++)
			arr[i]=new ArrayList<Integer>();
	}
	public static void addEdge(int v,int w)
	{
		arr[v].add(w);
		arr[w].add(v);
	}
	public static void dfs(int count,int v)
	{
		height[v]=0;
		depth[v]=count+1;
		for(int b:arr[v])
		{
			if(depth[b]==0)
				{
					dfs(depth[v],b);
					height[v]=Math.max(height[v], 1+height[b]);
				}
		}

	}
	public static void reach (int num,int x)
	{
		depth2[x]=num+1;
		for(int b:arr[x])
		{
			if(depth2[b]==0)
				reach(depth2[x],b);
		}
	}
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		x=sc.nextInt();
		int i=0,j=0;
		bowwow obj=new bowwow(n,x);
		for(i=0;i<n-1;i++)
		{
			int p=sc.nextInt();
			int q=sc.nextInt();
			obj.addEdge(p,q);
		}
		obj.reach(0,obj.x);
		obj.dfs( 0, 1);
		max=0;
		for( i=2;i<n+1;i++)
		if(depth2[i]<depth[i])
			max=Math.max(max, depth[i]+height[i]);
		System.out.print((max-1)*2);
	}
}


import java.util.PriorityQueue;
import java.util.*;
public class bowwow {

	private static ArrayList<Integer> arr[];
	private static int n;
	private static int x;
	private static int max;
	private static int num;
	private static int mnum;
	private static int count;
	private static int depth[];
	private static int depth2[];

	bowwow(int n1,int x1)
	{
		this.n=n1;
		this.x=x1;
		count=0;mnum=0;num=0;
		depth=new int[n+1];
		depth2=new int[n+1];
		Arrays.fill(depth, 0);
		Arrays.fill(depth2, 0);
		depth[0]=-1;
		depth2[0]=-1;
		arr=new ArrayList[n+1];
		int i=0;
		for(i=1;i<n+1;i++)
			arr[i]=new ArrayList<Integer>();
	}
	public static void addEdge(int v,int w)
	{
		arr[v].add(w);
		arr[w].add(v);
	}
	public static void dfs(bowwow T,int count,int v)
	{
		depth[v]=count+1;
		for(int b:T.arr[v])
		{
			if(depth[b]==0)
				dfs(T,depth[v],b);
		}

	}
	public static void reach (bowwow T,int num,int x)
	{
		depth2[x]=num+1;
		for(int b:T.arr[x])
		{
			if(depth2[b]==0)
				reach(T,depth2[x],b);
		}
	}

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		x=sc.nextInt();
		int i=0,j=0;
		bowwow obj=new bowwow(n,x);
		for(i=0;i<n-1;i++)
		{
			int p=sc.nextInt();
			int q=sc.nextInt();
			obj.addEdge(p,q);
		}
		obj.reach(obj,0,obj.x);
		obj.dfs(obj, 0, 1);
		max=0;
		for( i=2;i<n+1;i++)
		if(depth2[i]<depth[i] && max<depth[i] && arr[i].size()==1)
			max=depth[i];
		System.out.print((max-1)*2);
	}
}


import java.util.PriorityQueue;
import java.util.*;
public class bowwow {

	private static ArrayList<Integer> arr[];
	private static int n;
	private static int x;
	private static int max;
	private static int num;
	private static int mnum;
	private static int count;
	private static int depth[];
	private static int depth2[];

	bowwow(int n1,int x1)
	{
		this.n=n1;
		this.x=x1;
		count=0;mnum=0;num=0;
		depth=new int[n+1];
		depth2=new int[n+1];
		Arrays.fill(depth, 0);
		Arrays.fill(depth2, 0);

		arr=new ArrayList[n+1];
		int i=0;
		for(i=1;i<n+1;i++)
			arr[i]=new ArrayList<Integer>();
	}
	public static void addEdge(int v,int w)
	{
		arr[v].add(w);
		arr[w].add(v);
	}
	public static void dfs(bowwow T,int count,int v)
	{
		depth[v]=count+1;
		for(int b:T.arr[v])
		{
			if(depth[b]==0)
				dfs(T,depth[v],b);
		}

	}
	public static void reach (bowwow T,int num,int x)
	{
		depth2[x]=num+1;
		for(int b:T.arr[x])
		{
			if(depth2[b]==0)
				reach(T,depth2[x],b);
		}
	}

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		x=sc.nextInt();
		int i=0,j=0;
		bowwow obj=new bowwow(n,x);
		for(i=0;i<n-1;i++)
		{
			int p=sc.nextInt();
			int q=sc.nextInt();
			obj.addEdge(p,q);
		}
		obj.reach(obj,0,obj.x);
		obj.dfs(obj, 0, 1);
		max=0;
		for( i=2;i<n+1;i++)
		if(depth2[i]<depth[i] && max<depth[i] && arr[i].size()==1)
			max=depth[i];
		System.out.print((max-1)*2);
	}
}


//package educational.round22;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class C {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni(), x = ni()-1;
		int[] from = new int[n - 1];
		int[] to = new int[n - 1];
		for (int i = 0; i < n - 1; i++) {
			from[i] = ni() - 1;
			to[i] = ni() - 1;
		}
		int[][] g = packU(n, from, to);
		int[][] pars = parents3(g, 0);
		int[] par = pars[0], ord = pars[1], dep = pars[2];

		int[][] bpars = parents3(g, x);
		int[] bdep = bpars[2];
		int max = 0;
		for(int i = 0;i < n;i++){
			if(dep[i] < bdep[i])continue;
			max = Math.max(max, dep[i]*2);
		}
		out.println(max);
	}

	public static int[][] parents3(int[][] g, int root) {
		int n = g.length;
		int[] par = new int[n];
		Arrays.fill(par, -1);

		int[] depth = new int[n];
		depth[0] = 0;

		int[] q = new int[n];
		q[0] = root;
		for (int p = 0, r = 1; p < r; p++) {
			int cur = q[p];
			for (int nex : g[cur]) {
				if (par[cur] != nex) {
					q[r++] = nex;
					par[nex] = cur;
					depth[nex] = depth[cur] + 1;
				}
			}
		}
		return new int[][] { par, q, depth };
	}

	static int[][] packU(int n, int[] from, int[] to) {
		int[][] g = new int[n][];
		int[] p = new int[n];
		for (int f : from)
			p[f]++;
		for (int t : to)
			p[t]++;
		for (int i = 0; i < n; i++)
			g[i] = new int[p[i]];
		for (int i = 0; i < from.length; i++) {
			g[from[i]][--p[from[i]]] = to[i];
			g[to[i]][--p[to[i]]] = from[i];
		}
		return g;
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new C().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


//package educational.round22;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Queue;

public class C {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni(), x = ni()-1;
		int[] from = new int[n - 1];
		int[] to = new int[n - 1];
		for (int i = 0; i < n - 1; i++) {
			from[i] = ni() - 1;
			to[i] = ni() - 1;
		}
		int[][] g = packU(n, from, to);
		int[][] pars = parents3(g, 0);
		int[] par = pars[0], ord = pars[1], dep = pars[2];

		int[][] bpars = parents3(g, x);
		int[] bdep = bpars[2];
		int max = 0;
		Queue<Integer> q = new ArrayDeque<>();
		q.add(x);
		boolean[] can = new boolean[n];
		can[x] = true;
		while(!q.isEmpty()){
			int cur = q.poll();
			for(int e : g[cur]){
				if(!can[e] && bdep[e] <= dep[e]){
					can[e] = true;
					if(bdep[e] < dep[e]){
						q.add(e);
					}
				}
			}
		}
		for(int i = 0;i < n;i++){
			if(can[i])max = Math.max(max, dep[i]*2);
		}
		out.println(max);
	}

	public static int[][] parents3(int[][] g, int root) {
		int n = g.length;
		int[] par = new int[n];
		Arrays.fill(par, -1);

		int[] depth = new int[n];
		depth[0] = 0;

		int[] q = new int[n];
		q[0] = root;
		for (int p = 0, r = 1; p < r; p++) {
			int cur = q[p];
			for (int nex : g[cur]) {
				if (par[cur] != nex) {
					q[r++] = nex;
					par[nex] = cur;
					depth[nex] = depth[cur] + 1;
				}
			}
		}
		return new int[][] { par, q, depth };
	}

	static int[][] packU(int n, int[] from, int[] to) {
		int[][] g = new int[n][];
		int[] p = new int[n];
		for (int f : from)
			p[f]++;
		for (int t : to)
			p[t]++;
		for (int i = 0; i < n; i++)
			g[i] = new int[p[i]];
		for (int i = 0; i < from.length; i++) {
			g[from[i]][--p[from[i]]] = to[i];
			g[to[i]][--p[to[i]]] = from[i];
		}
		return g;
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new C().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class codeforces implements Runnable
{
	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars==-1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
		}
		public int nextInt()
		{
			int c = read();

			while(isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;
			do
			{
				if(c<'0'||c>'9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));
				return res * sgn;
		}

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			}
			while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next()
		{
			return readString();
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}

	public static void main(String args[]) throws Exception
	{
		new Thread(null, new codeforces(),"codeforces",1<<26).start();
	}

	public void run() {

		InputReader s = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);

		int n = s.nextInt();
		int v = s.nextInt();

		ArrayList<Integer>[] adj = new ArrayList[n + 1];

		for(int i = 1; i <= n; i++)
			adj[i] = new ArrayList<Integer>();

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

			int n1 = s.nextInt();
			int n2 = s.nextInt();

			adj[n1].add(n2);
			adj[n2].add(n1);
		}

		Queue<Integer> q = new LinkedList<Integer>();

		int[] level = new int[n + 1];
		Arrays.fill(level, -1);

		level[1] = 0;
		q.add(1);

		while(!q.isEmpty()) {

			int x = q.poll();

			for(int i = 0; i < adj[x].size(); i++) {

				int y = adj[x].get(i);

				if(level[y] == -1) {

					level[y] = level[x] + 1;
					q.add(y);
				}
			}
		}

		int[] level2 = new int[n + 1];
		Arrays.fill(level2, -1);

		level[v] = 0;
		q.add(v);

		while(!q.isEmpty()) {

			int x = q.poll();

			for(int i = 0; i < adj[x].size(); i++) {

				int y = adj[x].get(i);

				if(y == 1)
					continue;

				if(level[y] == -1) {

					level[y] = level[x] + 1;
					q.add(y);
				}
			}
		}

		int ans = 0;

		for(int i = 1; i <= n; i++) {

			if(level2[i] <= level[i] && level[i] > ans)
				ans = level[i];
		}

		w.println(ans * 2);

		w.close();
	}

}