#P46. [KBC003F] Training
[KBC003F] Training
Source
This problem is adapted from Long Long OJ. All rights reserved.
Problem Description
There are people, each with two attributes: combat power and stamina.
The coach of these people is going to train them, and each training session involves two people . One of the following training methods will be chosen:
- Person practices swordsmanship, increasing their combat power by 1, while person watches from the side, increasing their stamina by 1;
- Person practices swordsmanship, increasing their combat power by 1, while person watches from the side, increasing their stamina by 1.
Currently, pairs of people have been scheduled for training, and you get to decide the training method for each pair.
The coach wants every person's combat power and stamina to be even numbers. Your task is to find the minimum number of additional training sessions required.
Input Format
The first line contains two integers and . The next lines each contain two integers, representing the two people for each scheduled training session.
Output Format
Output a single integer, representing the minimum number of additional training sessions needed.
Samples
3 4
1 2
2 3
1 1
3 3
2
Sample Explanation
For convenience, a pair denotes that person 's combat power increases by 1 and person 's stamina increases by 1.
After the initial scheduled training sessions , the stamina and combat power of each person are as follows:
| ID | Stamina | Combat Power |
|---|---|---|
After conducting additional training sessions and , the stamina and combat power of each person become:
| ID | Stamina | Combat Power |
|---|---|---|
Data Range
For 100% of the data: , .