Hansu Numbers

Count integers from 1 to N (N up to 1000) whose digits form an arithmetic sequence.

Easy2ImplementationBrute forceMathInterviewNo attempts yetTime limit2sMemory limit128 MB

Problem

A positive integer X is called a Hansu number if its digits form an arithmetic sequence. In other words, the differences between every pair of adjacent digits are all the same. Given a natural number N, count how many integers from 1 through N are Hansu numbers.

Input

The first line contains a natural number N. N is at most 1,000.

Output

Print the number of Hansu numbers from 1 through N.