# AC(?)

import sys
from fractions import Fraction as frac
from itertools import permutations
input = sys.stdin.readline

n = int(input())

def check(p, a, b):
	return frac(p * a + b) / frac(p ** 2 - 1) > frac(1) / frac(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)