def solve():
    n = int(input())
    g = [[] for _ in range(n)]

    for _ in range(n - 1):
        a, b = [int(x) for x in input().split()]
        a -= 1
        b -= 1
        g[a].append(b)
        g[b].append(a)

    ds = dict()

    parent = [-1] * n
    dfs_order = [0]
    for i in range(n):
        a = dfs_order[i]
        for b in g[a]:
            if b == parent[a]:
                continue
            dfs_order.append(b)
            parent[b] = a

    vd = [-1] * n

    for a in reversed(dfs_order):
        vd[a] = 0
        for b in g[a]:
            if b == parent[a]:
                continue
            ds[(a, b)] = vd[b]
            vd[a] = max(vd[a], vd[b])

        vd[a] = vd[a] + 1

    ans = 0
    d_parent = [0] * n

    for a in dfs_order:
        cd = [(d_parent[a], parent[a])]
        for b in g[a]:
            if b == parent[a]:
                continue
            cd.append((ds[(a, b)], b))

        cd.sort()
        cd.reverse()

        cur = (cd[1][0] + 1) if (len(cd) > 1) else 1
        cur = min(cur, cd[0][0] - 1)
        ans += cur + 1

        for b in g[a]:
            if b == parent[a]:
                continue
            x = cd[0][0]
            if cd[0][1] == b:
                x = cd[1][0]
            d_parent[b] = x + 1

    print(ans + 1)


if __name__ == '__main__':
    # t = int(input())
    t=1
    for _ in range(t):
        solve()
