import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex;

void main() {
    auto N = readln.chomp.to!int;
    auto G = new int[][](N);
    foreach (_; 0..N-1) {
        auto s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1]-1;
        G[s[1]-1] ~= s[0]-1;
    }

    if (N % 2 == 1) {
        writeln(-1);
        return;
    }

    auto d = new int[](N);

    int dfs(int n, int p) {
        d[n] = 1;
        foreach (m; G[n]) if (m != p) d[n] += dfs(m, n);
        return d[n];
    }

    dfs(0, -1);
    auto ans = d.map!(a => 1 - a % 2).sum;
    writeln(ans - 1);
}
