Bus Lines
Time limit1sMemory limit128 MB
Partition the edges of a connected undirected graph into the fewest trails, where a trail may revisit cities but not edges.
Problem
In Byteotia there are cities connected by two-way roads, with many villages lying along those roads. King Byteasar has decided to create a network of bus lines serving the cities and villages. Each line may start and end in any city and may pass through any cities. A line may visit the same city more than once. However, no line may travel along the same road more than once.
To provide transport for all residents while keeping the investment cost as low as possible, the king decided that every road must be covered by exactly one bus line, and that the number of bus lines must be as small as possible.
In other words, partition all roads into a set of lines so that each road belongs to exactly one line, and make the number of lines as small as possible. A single line is a walk that never repeats a road (a trail); it may pass through the same city several times.
Input
The first line contains two integers and separated by a single space (, ), where is the number of cities and is the number of roads. Cities are numbered from to . Each of the next lines describes one road and contains two integers and separated by a single space (), the numbers of the two cities connected by that road. Each road appears in the input exactly once. Any two cities are directly connected by at most one road (although there may be many routes between two cities), and it is possible to travel between any two cities along the roads (the graph is connected).
Output
Output a single line containing one integer , the minimum number of bus lines needed.
Hint
