import qualified Data.ByteString.Char8 as B
import Data.Maybe
import Data.List
import Data.Array.IArray
import Control.Monad
 
data Player = Fennec | Snuke deriving (Eq,Show)
 
type Vertex = Int
type Edge = (Vertex,Vertex)
type Graph = Array Vertex [Vertex]
 
readPair :: B.ByteString -> [Edge]
readPair = (\[a,b] -> [(a,b),(b,a)]) . map (fst . fromJust . B.readInt) . B.words
 
groupFrom :: [Edge] -> [[Edge]]
groupFrom = groupBy (\(v1,_) (v2,_) -> v1 == v2)
 
main :: IO ()
main = do
 n <- readLn
 es <- sort . concatMap readPair . B.lines <$> B.getContents
 let g = array (1,n) $ map (\ps -> ((fst.head) ps, map snd ps)) (groupFrom es)
 print (versus n g)
 
--versus :: Vertex -> Graph -> Player
versus n g = (nf,ns) --if nf > ns then Fennec else Snuke
 where
  dmz = dfsDMZ g [] 0 1 n
  border = take 2 (drop (div (length dmz) 2 - 1) dmz) 
  nf = dfsDomain g 0 1 (head border)
  ns = dfsDomain g 0 n (last border)

dfsDMZ :: Graph -> [Vertex] -> Vertex -> Vertex -> Vertex -> [Vertex]
dfsDMZ g acc vp v vg
 | v == vg = v:acc
 | null next = mzero
 | otherwise = msum $ map (\vn -> dfsDMZ g (v:acc) v vn vg) next
 where next = delete vp (g!v)
 
dfsDomain :: Graph -> Vertex -> Vertex -> Vertex -> Int
dfsDomain g vp v vg
 | v == vg = 0
 | null next = 1
 | otherwise = 1 + sum (map (\vn -> dfsDomain g v vn vg) next)
 where next = delete vp (g!v)