# input n = int(input()) # brute force answer = 0 for a in range(0, 10): for b in range(0, 10): if a == b: continue # 0.ababab... = (pa+b) * (1/p^2 + 1/p^4 + ...) = (pa+b) / (p^2-1) l, r = max(a, b), 10 ** 27 while r - l > 1: m = (l + r) // 2 if n * (m * a + b) > m * m - 1: l = m else: r = m answer += l - max(a, b) # output print(answer)