# WA(?) import sys from itertools import permutations input = sys.stdin.readline n = int(input()) def check(p, a, b): return (p * a + b) / (p ** 2 - 1) > 1 / 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)