## Foxlings

View as PDF

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type

It's Christmas time in the forest, and both the fox and the wolf families are celebrating. The rather large fox family consists of two parents as well as little foxlings. The parents have decided to give their children a special treat this year – crackers! After all, it's a well-known fact that foxen love crackers.

With such a big family, the parents can't afford that many crackers. As such, they wish to minimize how many they give out, but still ensuring that each foxling gets at least a bit. The parents can only give out entire crackers, which can then be divided and passed around.

With this many children, not all of them know one another all that well. The foxlings have names, of course, but their parents are computer scientists, so they have also conveniently numbered them from 1 to . There are unique two-way friendships among the foxlings, where relationship is described by the distinct integers and , indicating that foxling is friends with foxling , and vice versa. When a foxling is given a cracker, he can use his tail to precisely split it into as many pieces as he wants (the tails of foxen have many fascinating uses). He can then pass these pieces around to his friends, who can repeat this process themselves.

#### Input Specification

Line : Two integers – and .
Next lines: Two integers – and .

#### Output Specification

The minimum number of crackers that must be given out so that each fox ends up with at least a bit of a cracker.

#### Sample Input

9 5
3 1
6 1
7 6
2 7
8 9

#### Sample Output

4

#### Explanation

The parents can give one cracker to foxling , who will then split it into three and give pieces to his friends (foxlings and ). Foxling can then give half of his piece to his other friend, foxling .

They can give another cracker to foxling , who will split it with foxling .

This leaves foxlings and , who have no friends (don't worry, foxen have long since outgrown the need for friends), and who must be given one cracker each. This brings the total up to crackers.

## Comments

There are no comments at the moment.