# AC(?) import sys from decimal import Decimal as dec from itertools import permutations input = sys.stdin.readline n = int(input()) def check(p, a, b): return dec(p * a + b) / dec(p ** 2 - 1) > dec(1) / dec(n) ans = 0 for a, b in permutations([*range(10)], 2): min_p = max(a, b) + 1 if not(check(min_p, a, b)): continue ok = min_p ng = 10 ** 9 + 1 while(ng - ok > 1): p = (ok + ng) >> 1 if(check(p, a, b)): ok = p else: ng = p ans += ok - min_p + 1 print(ans)