Under construction

Still being built. Things may change

Lights

Time limit1sMemory limit128 MB

Summary
Each switch toggles a light and its neighbors; find the minimum number of switches to press so that all N lights end up on.
Level

Hard8 of 10

Topics
Bit manipulation, Math, Brute force, Graph
Solved
No attempts yet

Problem

Bessie and the cows were playing games in the barn, but the power was reset and all the lights turned off. Help the cows turn every light back on so they can resume their games.

There are NN lights (1≤N≤351 \le N \le 35), numbered 1…N1 \ldots N. The lights and their switches are wired into a complex network with MM (1≤M≤5951 \le M \le 595) connections, each joining a pair of lights.

Every light has a switch. Toggling a switch flips that light and all of the lights directly connected to it — each of them changes state (on becomes off, off becomes on).

Find the minimum number of switches you must toggle to turn all the lights back on.

It is guaranteed that at least one way to toggle the switches turns every light on.

Input

  • Line 11: Two space-separated integers, NN and MM.
  • Lines 2…M+12 \ldots M+1: Each line contains two space-separated integers, the two lights joined by a connection. No pair is repeated.

Output

Print a single integer: the minimum number of switches that must be toggled to turn on all the lights.

Hint

There are 5 lights. Lights 1, 4, and 5 are each connected to both light 2 and light 3.

Toggle the switches on lights 1, 4, and 5.

Examples1

  1. Example 1

    Input
    5 6
    1 2
    1 3
    4 2
    3 4
    2 5
    5 3
    
    Expected output
    3