module.exports=function(t){var i={};function r(e){if(i[e])return i[e].exports;var n=i[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=i,r.d=function(t,i,e){r.o(t,i)||Object.defineProperty(t,i,{enumerable:!0,get:e})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,i){if(1&i&&(t=r(t)),8&i)return t;if(4&i&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&i&&"string"!=typeof t)for(var n in t)r.d(e,n,function(i){return t[i]}.bind(null,n));return e},r.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(i,"a",i),i},r.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},r.p="",r(r.s=0)}([function(t,i,r){"use strict";var e=r(1);r(2)(e.readFileSync("/dev/stdin","utf8"))},function(t,i){t.exports=require("fs")},function(t,i,r){"use strict";var e=r(3),n=r(5);t.exports=function(t){var i=new e(t);n(i)}},function(t,i,r){"use strict";var e=r(4);t.exports=class{constructor(t){var i=t.trim().split(/\s+/g);this.inp=new e(i)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,i,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,i,r){"use strict";t.exports=function(t){for(var i=t.in(),r=t.in()-1,e=t.in()-1,n=new Array(i),s=new Array(i),o=0;o<i;o++)n[o]=[],s[o]={visT:0,visA:0,disT:-1,disA:-1};for(var u=0;u<i-1;u++){var a=t.in()-1,d=t.in()-1;n[a].push(d),n[d].push(a)}s[e].visA=1,s[e].disA=0;for(var c=[{v:e,dis:0}];c.length>0;)for(var f=c.pop(),v=n[f.v],l=0;l<v.length;l++){var p=v[l];1!=s[p].visA&&(s[p].visA=1,s[p].disA=f.dis+1,c.push({v:p,dis:f.dis+1}))}s[r].visT=1,s[r].disT=0;for(var h=[{v:r,dis:0}];h.length>0;)for(var m=h.pop(),y=n[m.v],g=0;g<y.length;g++){var b=y[g];1!=s[b].visT&&(s[b].visT=1,s[b].disT=m.dis+1,h.push({v:b,dis:m.dis+1}))}for(var x=0,T=99999999999,A=!1,j=0;j<i;j++){if(s[j].disT-s[j].disA<0){var M=s[j].disT;x=Math.max(M,x)}s[j].disT-s[j].disA==0&&(A=!0,T=Math.min(T,s[j].disT))}var O=A?Math.max(x,T):x;console.log(O)}}]);
