Graph Flagging
题号:NC243978
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Cuber QQ receives a task that contains a graph with n vertices and n edges.

The graph does not contain multiple edges, and also does not contain self-loops. Besides, the graph is connected, which means each vertex can reach any other vertices through edges.

Cuber QQ will flag some vertices in the graph, which aims to make every vertex in the graph has exactly one flagged neighbor vertex.

Cuber QQ wants to know the least number of vertices that have to flag.

输入描述:

The first line contains one integer n (3\le n\le 10^5), the number of vertices and edges in the graph.

The following n lines contain two integers representing the edges of the graph.

输出描述:

Output one integer means the least number of vertices that have to flag.

If there is no solution, print a single integer -1.
示例1

输入

复制
4
1 2
2 3
3 4
4 1

输出

复制
2

说明

In sample 1, flag 1 and 2, and all the vertices will have exactly one neighbor vertex that has been flagged.
示例2

输入

复制
3
1 2
2 3
3 1

输出

复制
-1