{"problem":{"name":"L. PC is for kicking","description":{"content":"Otvio is a calm guy with a guilty pleasure: kicking PCs. Now he is participating in a programming competition where the computers are arranged as a tree, that is, the N PCs are connected by N - 1 cabl","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10187L"},"statements":[{"statement_type":"Markdown","content":"Otvio is a calm guy with a guilty pleasure: kicking PCs. Now he is participating in a programming competition where the computers are arranged as a tree, that is, the N PCs are connected by N - 1 cables and there is only one cable path from one PC to another.\n\nOtvio wants to kick as many PCs as possible. To do so, he will walk along a cable path, kicking all the PCs in the path. He will start at PC a, the one he will use in the contest. However, to prevent getting caught, he will not pass by PCs he already kicked nor kick any PC twice.\n\nLaerco, knowing Otvio's guilty pleasure, wants to know the maximum number of PCs Otvio can kick satisfying the conditions above. Remember that Otvio will kick his own PC for sure.\n\nThe first line of the input consist of two integers integer N and a (1 ≤ N, a ≤ 105), the number of PCs in the contest and the number of Otvio's PC, in this order. Each of the next N - 1 lines contains two integers u and v (1 ≤ u, v ≤ N), indicating that there is a cable connecting PCs u and v.\n\nOutput a single integer - the maximum number of PCs Otvio can kick.\n\n## Input\n\nThe first line of the input consist of two integers integer N and a (1 ≤ N, a ≤ 105), the number of PCs in the contest and the number of Otvio's PC, in this order. Each of the next N - 1 lines contains two integers u and v (1 ≤ u, v ≤ N), indicating that there is a cable connecting PCs u and v.\n\n## Output\n\nOutput a single integer - the maximum number of PCs Otvio can kick.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ N \\in \\mathbb{Z}^+ $ be the number of PCs, and $ a \\in \\{1, \\dots, N\\} $ be the starting PC.  \nLet $ T = (V, E) $ be a tree with vertex set $ V = \\{1, \\dots, N\\} $ and edge set $ E $ of size $ N-1 $.  \n\n**Constraints**  \n1. $ 1 \\leq N \\leq 10^5 $  \n2. $ 1 \\leq a \\leq N $  \n3. Each edge $ (u, v) \\in E $ connects distinct vertices $ u, v \\in V $.  \n\n**Objective**  \nFind the maximum number of vertices in a simple path starting at vertex $ a $ in tree $ T $.  \nThat is, compute the length (in vertices) of the longest path beginning at $ a $, where no vertex is revisited.  \n\nThis is equivalent to:  \n$$\n\\max_{P \\in \\mathcal{P}_a} |P|\n$$  \nwhere $ \\mathcal{P}_a $ is the set of all simple paths in $ T $ starting at $ a $.  \n\nEquivalently, it is the maximum distance (in vertices) from $ a $ to any leaf in $ T $, where distance is measured as the number of vertices along the path.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10187L","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}