Skip to main content
LIVE CONTEST: Round #7 · Begin Marathon is live now! …

~/algor $ cat problems/yolni-boyash

Painting the road

Author Iqbolshoh Ilhomjonov 3 @iqbolshoh 636 problems
Medium 1000 ms 128 MB 38%
Share

A road is divided into cells numbered from to . painters worked: painter painted one coat on every cell from cell to cell (both included). How many cells have at least coats?

A road of ten cells, four painted segments and the number of coats on each cell; cells with at least 2 coats are highlighted

Input

The first line contains three positive integers: , and . Line of the next lines contains two positive integers: and .

Output

One integer — the number of cells.

Note




Examples

Input #1
10 4 2
1 4
3 7
6 9
2 3
Output #1
5
Input #2
5 2 2
1 2
4 5
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.