Unlucky numbers

Professor Oak has many quirks. For instance, he thinks that the
multiples of 13 are unlucky: 13, 26, 39, 52, …. Moreover, for some
reason he also dislikes numbers like 174, “because” its distance to the
next century is a (strictly positive) multiple of 13: 200 − 174 = 26.
For the same reason he disaproves numbers like 1061 or 48:
1100 − 1061 = 39, 100 − 48 = 52. Note that some numbers like 1287 are
doubly disliked: 1287 = 99 ⋅ 13, 1300 − 1287 = 13.

Given a number n, can you count how many numbers between 1 and n are
liked?

Input

Input consists of several natural numbers n, each one between 1 and
10¹⁵.

Output

For every n, print the quantity of numbers in [1, n] liked by Professor
Oak.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T10:33:00.600Z

© Jutge.org, 2006–2026.
https://jutge.org
