FOXLINGS - Foxlings

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 $N$ ($1 \leq N \leq 10^9$) 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 insure 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 $N$. There are $M$ ($1 \leq M \leq 10^5$) unique two-way friendships among the Foxlings, where relationship $i$ is described by the distinct integers $A_i$ and $B_i$ ($1 \leq A_i,B_i \leq N$), indicating that Foxling $A_i$ is friends with Foxling $B_i$, 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

Line $1$: 2 integers, $N$ and $M$

Next $M$ lines: 2 integers, $A_i$ and $B_i$, for $i=1..M$

Output

A single integer – the minimum number crackers must be given out, such that each Foxling ends up with at least a small part of a cracker.

Example

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

Output:
4

Explanation of Sample:

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

They can give another cracker to Foxling 8, who will split it with Foxling 9.

This leaves Foxlings 4 and 5, 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 4 crackers.


Added by:SourSpinach
Date:2013-05-07
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own problem

hide comments
2017-01-24 06:03:11
TL is very strict
2016-12-22 09:05:57 Mayank Agarwal
can be done without DSU!!
2016-08-25 14:35:46
maps :D
2016-07-05 12:38:09 Siddharth Singh
Pretty Nice.
Couldn't Be possible without Nalin Sir(naruto09)(This Problem's Best Solver) Help .
DSU :P <3
2016-02-04 16:32:55 Liquid_Science
More than 1 sec,but still fastest in java, I am happy though ,at least judge accepted java solutions
2015-05-30 07:09:20 parijat bhatt
my bad, got it.
2015-05-30 06:32:27 parijat bhatt
Ai and Bi are <=N or strictly less than M
mean what is the upper bound on A & B?

Last edit: 2015-05-30 06:33:43
2015-05-24 18:23:20
Have tried every possible case but still WA don't know whats the problem....please provide me a tricky case which you think will not pass.
Thanks
2014-12-24 22:53:26 shakaal
ਪਾਜੀ ਅੱਤ ਕਰਾ ਛੋਡੀ ਜੇ ...ਔਸਮ -^-
2014-10-03 11:33:25 sobriquet
Catch the trick and njoy!!!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.