Preparando MOJI

Digital Root

2000ms 262144K

Description:

Not long ago Billy came across such a problem, where there were given three natural numbers A, B and C from the range [1, N], and it was asked to check whether the equation AB = C is correct. Recently Billy studied the concept of a digital root of a number. We should remind you that a digital root d(x) of the number x is the sum s(x) of all the digits of this number, if s(x) ≤ 9, otherwise it is d(s(x)). For example, a digital root of the number 6543 is calculated as follows: d(6543) = d(6 + 5 + 4 + 3) = d(18) = 9. Billy has counted that the digital root of a product of numbers is equal to the digital root of the product of the factors' digital roots, i.e. d(xy) = d(d(x)d(y)). And the following solution to the problem came to his mind: to calculate the digital roots and check if this condition is met. However, Billy has doubts that this condition is sufficient. That's why he asks you to find out the amount of test examples for the given problem such that the algorithm proposed by Billy makes mistakes.

Input:

The first line contains the only number N (1 ≤ N ≤ 106).

Output:

Output one number — the amount of required A, B and C from the range [1, N].

Sample Input:

4

Sample Output:

2

Sample Input:

5

Sample Output:

6

Note:

For the first sample the required triples are (3, 4, 3) and (4, 3, 3).

Informação

Codeforces

Provedor Codeforces

Código CF10C

Tags

number theory

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 08:26:42

Relacionados

Nada ainda