SP8952 THRBL - Catapult that ball

Description

Bob has unusual problem. In Byteland we can find a lot of hills and cities. King of Byteland ordered Bob to deliver magic balls from one city to another. Unfortunately, Bob has to deliver many magic balls, so walking with them would take too much time for him. Bob came up with great idea - catapulting them. Byteland is divided into intervals. Each interval contains city and hill. Bob can catapult magic ball accurately from city A to city B, if between them there isn't higher hill than A's hill.

Input Format

Every test case contains N and M (N

Output Format

Write one number - number of magic balls that Bob can catapult successfully.