import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;

void main() {
    int n;
    scan(n);

    auto adj = new int[][](n, 0);
    foreach (i ; 0 .. n-1) {
        int ai,bi;
        scan(ai,bi);
        adj[ai] ~= bi;
        adj[bi] ~= ai;
    }

    auto d = new int[](n);
    auto par = new int[](n);

    void dfs(int v, int p, int dist) {
        d[v] = dist;
        foreach (u ; adj[v]) {
            if (u != p) {
                par[u] = v;
                dfs(u, v, dist + 1);
            }
        }
    }

    dfs(0, -1, 0);

    int s, dmax;

    foreach (i ; 0 .. n) {
        if (dmax < d[i]) {
            dmax = d[i];
            s = i;
        }
    }

    dfs(s, -1, 0);

    int t;
    dmax = 0;

    foreach (i ; 0 .. n) {
        if (dmax < d[i]) {
            dmax = d[i];
            t = i;
        }
    }

    debug {
        writeln(s, ' ', t);
        writeln(d);
    }

    auto visited = new bool[](n);
    visited[s] = visited[t] = 1;

    int ans = 2, pos = t;

    while (pos != s) {
        pos = par[pos];
        ans += max(0, adj[pos].length.to!int - 3);
        visited[pos] = 1;
    }

    if (visited.all) {
        writeln(1);
    }
    else {
        writeln(ans);
    }
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
