import sys from functools import lru_cache sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) N = I() Graph = [[] for _ in range(N)] for _ in range(N-1): u,v = MI() u -= 1 v -= 1 Graph[u].append(v) Graph[v].append(u) @lru_cache(maxsize=None) def dfs(i,par,r): res = 0 if len(Graph[i]) == 1 and par == Graph[i][0]: if not r: res = 1 else: if not r: res += 1 for j in Graph[i]: if j != par: if r: res += max(dfs(j,i,0),dfs(j,i,1)) else: res += max(dfs(j,i,0)-1,dfs(j,i,1)) return res ans = max(dfs(0,-1,0),dfs(0,-1,1)) print(ans)