local n = io.read("*n") local t = {} local removed = {} for i = 1, n do t[i] = {} removed[i] = false end for i = 1, n - 1 do local a, b = io.read("*n", "*n") table.insert(t[a], b) table.insert(t[b], a) end local tasks = {} local tasknum, done = 0, 0 for i = 1, n do if #t[i] == 1 then tasknum = tasknum + 1 table.insert(tasks, i) end end local cnt = 0 while done < tasknum do done = done + 1 local curidx = tasks[done] for i = 1, #t[curidx] do local dstidx = t[curidx][i] if not removed[dstidx] then removed[dstidx] = true for j = 1, #t[dstidx] do local dstdstidx = t[dstidx][j] local tmp = 0 for k = 1, #t[dstdstidx] do local dddidx = t[dstdstidx][k] if not removed[dddidx] then tmp = tmp + 1 end end if tmp == 0 then cnt = cnt + 1 elseif tmp == 1 then tasknum = tasknum + 1 table.insert(tasks, dstdstidx) end end break end end end print(cnt)