Brazen Horseflies
Horseflies have become a real nuisance for the LKS. This morning, I woke up to find n pesky horseflies on the window, just waiting for me to put on shorts and head out for a workout. Do I have to endure wearing jeans all day in this heat again?
Not this time. I quickly calculated the coordinates of the horseflies on the window and determined the audacity of each one. Their audacity is represented by positive numbers. It's time to put to use the round fly swatter I bought in Sudislavl, which has a radius of r. When k horseflies are hit by the swatter, the audacity of each one decreases by 1/k units. Once a horsefly's audacity is no longer positive, it will realize its mistake and fly away.
What is the minimum number of times I need to strike the glass with the fly swatter to get rid of all the horseflies?
Input
The first line contains the integers n and r (1 ≤ n, r ≤ 1000) - the number of horseflies and the radius of the fly swatter. Each of the next n lines provides the coordinates of a horsefly and its audacity. All coordinates and audacities are positive integers not exceeding 1000. No two horseflies share the same location.
Output
Output a single number - the minimum number of times you need to hit the glass with the fly swatter to make the audacity of all horseflies non-positive.