{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eWe have a tree with \u003cvar\u003e\\(N\\)\u003c/var\u003e vertices. The \u003cvar\u003e\\(i\\)\u003c/var\u003e-th edge connects Vertex \u003cvar\u003e\\(A_i\\)\u003c/var\u003e and \u003cvar\u003e\\(B_i\\)\u003c/var\u003e bidirectionally.\u003c/p\u003e\r\n\u003cp\u003eTakahashi is standing at Vertex \u003cvar\u003e\\(u\\)\u003c/var\u003e, and Aoki is standing at Vertex \u003cvar\u003e\\(v\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003cp\u003eNow, they will play a game of tag as follows:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\r\n\u003cp\u003e\u003cvar\u003e\\(1\\)\u003c/var\u003e. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Takahashi moves to a vertex of his choice that is adjacent to his current vertex.\u003c/p\u003e\r\n\u003c/li\u003e\r\n\u003cli\u003e\r\n\u003cp\u003e\u003cvar\u003e\\(2\\)\u003c/var\u003e. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Aoki moves to a vertex of his choice that is adjacent to his current vertex.\u003c/p\u003e\r\n\u003c/li\u003e\r\n\u003cli\u003e\r\n\u003cp\u003e\u003cvar\u003e\\(3\\)\u003c/var\u003e. Go back to step \u003cvar\u003e\\(1\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cp\u003eTakahashi performs his moves so that the game ends as late as possible, while Aoki performs his moves so that the game ends as early as possible.\u003c/p\u003e\r\n\u003cp\u003eFind the number of moves Aoki will perform before the end of the game if both Takahashi and Aoki know each other\u0027s position and strategy.\u003c/p\u003e\r\n\u003cp\u003eIt can be proved that the game is bound to end.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Constraints","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(2 \\leq N \\leq 10^5\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq u,v \\leq N\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(u \\neq v\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq A_i,B_i \\leq N\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003eThe given graph is a tree.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Input","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eInput is given from Standard Input in the following format:\u003c/p\u003e\r\n\u003cpre\u003e\u003cvar\u003e\\(N\\)\u003c/var\u003e \u003cvar\u003e\\(u\\)\u003c/var\u003e \u003cvar\u003e\\(v\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(A_1\\)\u003c/var\u003e \u003cvar\u003e\\(B_1\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(:\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(A_{N-1}\\)\u003c/var\u003e \u003cvar\u003e\\(B_{N-1}\\)\u003c/var\u003e\r\n\u003c/pre\u003e\r\n\r\n\u003c/section\u003e\r\n"}},{"title":"Output","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003ePrint the number of moves Aoki will perform before the end of the game.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5 4 1\r\n1 2\r\n2 3\r\n3 4\r\n3 5\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eIf both players play optimally, the game will progress as follows:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eTakahashi moves to Vertex \u003cvar\u003e\\(3\\)\u003c/var\u003e.\u003c/li\u003e\r\n\u003cli\u003eAoki moves to Vertex \u003cvar\u003e\\(2\\)\u003c/var\u003e.\u003c/li\u003e\r\n\u003cli\u003eTakahashi moves to Vertex \u003cvar\u003e\\(5\\)\u003c/var\u003e.\u003c/li\u003e\r\n\u003cli\u003eAoki moves to Vertex \u003cvar\u003e\\(3\\)\u003c/var\u003e.\u003c/li\u003e\r\n\u003cli\u003eTakahashi moves to Vertex \u003cvar\u003e\\(3\\)\u003c/var\u003e.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cp\u003eHere, Aoki performs two moves.\u003c/p\u003e\r\n\u003cp\u003eNote that, in each move, it is prohibited to stay at the current vertex.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 2","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5 4 5\r\n1 2\r\n1 3\r\n1 4\r\n1 5\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 3","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2 1 2\r\n1 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 4","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e9 6 1\r\n1 2\r\n2 3\r\n3 4\r\n4 5\r\n5 6\r\n4 7\r\n7 8\r\n8 9\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\u003c/section\u003e\r\n"}}]}