Trams#1056

Trams

5 seconds
64 megabytes
Easy

\includegraphics{https://static.e-olymp.com/content/1b/1b6a6c4b2fe21576d8d9b7f60888166f9d68ba04.jpg}

The government of the city of Riverside decided to improve the transport situation in the city. To achieve this, a network of tram lines connecting tram stops was built. For the convenience of passengers, it was possible to travel by tram between every pair of stops. On the other hand, for cost-saving purposes, there was only one possible route between any two stops. Formally, the tram network is a tree with vertices, where the vertices correspond to stops, and the edges correspond to tram lines.

Initially, each tram line was used by at least one tram route. Over time, however, some routes were discontinued, and as a result, some tram lines became unused. A tram line is considered unused if no tram route passes through it. To save resources, it was decided to dismantle the unused tram lines in Riverside.

Your task is to write a program to determine the number of unused tram lines.

Illustration for the second example. The dotted line indicates an unused tram line.

Input

The first line contains a single integer — the number of tram stops in the city (2 \leq n \leq 100000). Each of the next n-1 lines describes a tram line (i.e., an edge of the tree). Each description consists of two integers and — the numbers of the stops connected by the corresponding tram line. The stops are numbered from to .

The next line contains the integer — the number of tram routes (0 \leq m \leq 100000). Each of the following lines describes one tram route. Each description consists of two integers and , which are the terminal stops of the route. The tram route goes along the shortest path between and (x \neq y).

Output

Output the number of unused tram lines in Riverside.

Examples

Example 1

Loading
Loading