from collections import defaultdict
dp = defaultdict(lambda : 0)
s = input()
a = list(map(lambda x : ord(x) - ord('0'), s))
dp[(0, 0, 0, 0)] = 1
for i in range(len(s)):
for nz in (0, 1):
for ls in (0, 1):
for mask in range(1 << 10):
for d in range(0, 10):
if d > a[i] and not ls:
continue
nmask = mask
if d != 0 or nz:
nmask |= (1 << d);
dp[(i + 1, nz | (d != 0), ls | (d < a[i]), nmask)] += dp[(i, nz, ls, mask)];
cnt = [0] * 1024
for nz in (0, 1):
for ls in (0, 1):
for mask in range(1 << 10):
cnt[mask] += dp[(len(s), nz, ls, mask)]
ans = 0;
for a in range(1, 1 << 10):
for b in range(1, 1 << 10):
if (a & b) != 0:
ans += cnt[a] * cnt[b]
print(ans)