VK Cup 2012 Finals, Practice Session
C
Trails and Glades
Codeforces
2400
原题
← B→
翻译中…

Vasya went for a walk in the park. The park has $*n*$ glades, numbered from 1 to $*n*$. There are $*m*$ trails between the glades. The trails are numbered from 1 to $*m*$, where the $*i*$-th trail connects glades $*x*_{*i*}$ and $*y*_{*i*}$. The numbers of the connected glades may be the same $(*x*_{*i*} = *y*_{*i*})$, which means that a trail connects a glade to itself. Also, two glades may have several non-intersecting trails between them.

翻译中…

Vasya is on glade 1, he wants to walk on all trails of the park exactly once, so that he can eventually return to glade 1. Unfortunately, Vasya does not know whether this walk is possible or not. Help Vasya, determine whether the walk is possible or not. If such walk is impossible, find the minimum number of trails the authorities need to add to the park in order to make the described walk possible.

翻译中…

Vasya can shift from one trail to another one only on glades. He can move on the trails in both directions. If Vasya started going on the trail that connects glades $*a*$ and $*b*$, from glade $*a*$, then he must finish this trail on glade $*b*$.

翻译中…

Input

翻译中…

The first line contains two integers $*n*$ and $*m*$ $(1 ≤ *n* ≤ 10^{6}; 0 ≤ *m* ≤ 10^{6})$ — the number of glades in the park and the number of trails in the park, respectively. Next $*m*$ lines specify the trails. The $*i*$-th line specifies the $*i*$-th trail as two space-separated numbers, $*x*_{*i*}$, $*y*_{*i*}$ $(1 ≤ *x*_{*i*}, *y*_{*i*} ≤ *n*)$ — the numbers of the glades connected by this trail.

翻译中…

Output

翻译中…

Print the single integer — the answer to the problem. If Vasya's walk is possible without adding extra trails, print 0, otherwise print the minimum number of trails the authorities need to add to the park in order to make Vasya's walk possible.

翻译中…

Note

翻译中…

In the first test case the described walk is possible without building extra trails. For example, let's first go on the first trail, then on the second one, and finally on the third one.

翻译中…

In the second test case the described walk is impossible without adding extra trails. To make the walk possible, it is enough to add one trail, for example, between glades number one and two.

翻译中…

样例

Input #1
3 3
1 2
2 3
3 1
Output #1
0
InputCopy OutputCopy
Input #2
2 5
1 1
1 2
1 2
2 2
1 2
Output #2
1
InputCopy OutputCopy
题目信息
题号
209C
时间限制
4 s
内存限制
256 MB
标签
构造
并查集
图论
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。