The Resistance is trying to take control over all planets in a particular solar system. This solar system is shaped like a tree. More precisely, some planets are connected by bidirectional hyperspace tunnels in such a way that there is a path between every pair of the planets, but removing any tunnel would disconnect some of them.
The Resistance already has measures in place that will, when the time is right, enable them to control every planet that is not remote. A planet is considered to be remote if it is connected to the rest of the planets only via a single hyperspace tunnel.
How much work is there left to be done: that is, how many remote planets are there?
Output
A single integer denoting the number of remote planets.
Note
In the first example, only planets 2, 3 and 5 are connected by a single tunnel.
In the second example, the remote planets are 2 and 3.
Note that this problem has only two versions – easy and medium.
Примеры
| № | Входные данные | Выходные данные |
|
1
|
5 4 1 4 2 1 3 1 5
|
3
|
|
2
|
4 1 2 4 3 1 4
|
2
|