Mika wants to make some cherry cakes to eat.
The forest Mika lives can be considered as a two-dimensional Cartesian coordinate. Mika's home is located on
)
.
In the forest, the speed of Mika and merchant is same. If you want to go from
)
to
)
, you will cost

seconds, which is the Manhattan distance between them.
If one person if on
)
, when he
go up for

seconds, he will be at
)
,
go down for

seconds, he will be at
)
,
go right for

seconds, he will be at
)
,
go left for

seconds, he will be at
)
.
Notice:

may not be an integer.
Now Mika knows that there will be

merchants travel through this forest. The

merchant will be at
(x_i%5Cgeq%201%2C%20y_i%20%5Cgeq%201))
at time

and the diraction of each merchant will be given.
Mika will be at his home at time

, when he and a merchant are at the same point, he can buy a basket of cherry, and return to the home to drop the basket, then he goes to find the second merchant and so on.
You can consider the time Mika spends on buying cherries and dropping the basket at home is

.
Mika is a fairy, so he can't hold two or more baskets of cherry, so he can only buy one basket of cherry and return home to drop the basket.
Now Mika wants to know the maximum baskets of cherry he can buy?