409331: GYM103485 M Constellation collection

Memory Limit:512 MB Time Limit:10 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

M. Constellation collectiontime limit per test10 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

The Egyptian pharaohs are very fond of astronomy and constellations, because they think that after death, their spirit turns into a star in the sky.

One day, the priests of Pharaoh Tutankhamun decided to create the concept of non-fungibility and are planning to create a market to buy stars, Tutankhamun learned about this market and as he idolized some constellations in the sky, he asked his priests to have the possession of these stars.

No stars have been bought yet, Tutankhamun can buy stars before everyone else and take possession of those stars, Tutankhamun wants to own $$$n$$$ stars.

In this market there is a special rule: when we take possession of a star $$$E$$$, all stars that have no owner and have a distance less than or equal to $$$c$$$ are owned by whoever obtained the star $$$E$$$.

As pharaoh's priest, help Tutankhamun buy the least amount of stars to have all the stars pharaoh wants.

Input

The first line has two integers $$$n$$$ and $$$c$$$, where $$$1 \leq n \leq 5 \cdot 10^5$$$ and $$$1 \leq c \leq 10^6$$$, where n is the set of stars that Tutankhamun want and c is the proximity constant for obtaining new stars.

In the next $$$n$$$ lines, we have pairs of numbers ($$$x_i$$$, $$$y_i$$$) indicating the coordinates of the stars that Tutankhamun wants.

The coordinates of the stars are non-negative integers where the absolute value is no more than $$$10^6$$$ and there is also no pair of stars with the same coordinate.

Output

The output consists of the minimum amount of stars you need to buy to have all the stars that Tutankhamun wants.

ExamplesInput
5 3
0 3
5 4
3 4
2 6
3 0
Output
3
Input
7 4
0 1
6 3
10 2
14 3
23 10
24 4
17 0
Output
7

加入题单

算法标签: