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

题目描述

Given a tree with n nodes numbered from 1 to n.

Alice wants to know the number of connected components with a size of three in the tree.

输入描述:

The first line contain a single integer n (1\leq n\leq 10^5), denoting the number of nodes in the tree.

In the next n-1 lines, each line contain two integers u and v (1\leq u,v\leq n), indicating that there is an edge between node u and node v.

输出描述:

Output an integer in a single line, indicating the number of connected components with a size of three in the tree.
示例1

输入

复制
3
1 2
2 3

输出

复制
1
示例2

输入

复制
5
1 2
1 3
1 4
2 5

输出

复制
4