CF209C.Trails and Glades

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya went for a walk in the park. The park has nn glades, numbered from 1 to nn . There are mm trails between the glades. The trails are numbered from 1 to mm , where the ii -th trail connects glades xix_{i} and yiy_{i} . The numbers of the connected glades may be the same (xi=yi)(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 aa and bb , from glade aa , then he must finish this trail on glade bb .

输入格式

The first line contains two integers nn and mm (1<=n<=106; 0<=m<=106)(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 mm lines specify the trails. The ii -th line specifies the ii -th trail as two space-separated numbers, xix_{i} , yiy_{i} (1<=xi,yi<=n)(1<=x_{i},y_{i}<=n) — the numbers of the glades connected by this trail.

输出格式

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.

输入输出样例

  • 输入#1

    3 3
    1 2
    2 3
    3 1
    

    输出#1

    0
    
  • 输入#2

    2 5
    1 1
    1 2
    1 2
    2 2
    1 2
    

    输出#2

    1
    

说明/提示

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.

首页