#include <bits/stdc++.h>

const int MAXN = 1e5 + 5;

int ccnt[MAXN];

struct Tree
{
    struct Edge
    {
        int v, next;
    } es[MAXN];

    int n, tot;
    int head[MAXN];

    void init()
    {
        tot = 0;
        memset(head, -1, sizeof(head));
    }

    void addEdge(int u, int v)
    {
        es[tot].v = v;
        es[tot].next = head[u];
        head[u] = tot++;
    }

    int dfs(int root, int fa)
    {
        int chd = ccnt[root] - 1;
        int res = 0;

        bool pri = false;
        for (int e = head[root]; e != -1; e = es[e].next)
        {
            if (es[e].v == fa) continue;

            int ndfs = dfs(es[e].v, root);
            if (ndfs == 0)
            {
                if (pri) res++;
                else pri = true;
            }
            res += ndfs;
        }

        return res;
    }
};

int main()
{
    static Tree tr;
    scanf("%d", &tr.n);

    tr.init();

    int root = -1;
    for (int i = 0; i < tr.n - 1; i++)
    {
        int u, v;
        scanf("%d%d", &u, &v);

        tr.addEdge(u, v);
        tr.addEdge(v, u);

        if (++ccnt[u] >= 3) root = u;
        if (++ccnt[v] >= 3) root = v;
    }

    if (root == -1) printf("-1");
    else printf("%d", tr.dfs(root, -1));
}