Arithmetic derivative

Given a natural number nn, its arithmetic derivative d(n)d(n) is defined as follows:

For instance, d(4)=2d(2)+2d(2)=2+2=4d(4) = 2d(2) + 2d(2) = 2 + 2 = 4, and d(6)=3d(2)+2d(3)=3+2=5d(6) = 3d(2) + 2d(3) = 3 + 2 = 5. It can be proven that this definition is consistent. For example, d(12)=4d(3)+3d(4)=4+12=16d(12) = 4d(3) + 3d(4) = 4 + 12 = 16, and also d(12)=6d(2)+2d(6)=6+10=16d(12) = 6d(2) + 2d(6) = 6 + 10 = 16.

We say that ff is a fixed point of d(n)d(n) if d(f)=fd(f) = f. For instance, 0 and 4 are fixed points. Given \ell and rr, can you compute the number of fixed points of d(n)d(n) in [..r][\ell..r]?

Input

Input consists of several cases, each one with \ell and rr, with 0r10180 \le \ell \le r \le 10^{18}.

Output

For each case, print the number of fixed points of d(n)d(n) in [..r][\ell..r].

Problem information

Author: Salvador Roura

Generation: 2026-01-25T12:08:07.407Z

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