p = set() def is_pandigital(n, s=9): return len(n)==s and not '1234567890'[:s].strip(n) def calc (n): for i in range(2, 99): j = i+1 while i*j < 8999: if is_pandigital(str(i)+str(j)+str(i*j), n): p.add(i*j) j+= 1 return sum(p) print (calc(int(input())))