#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL dp[12][2][2][1024]; // dp[pos][nonzero][less][mask]
LL cnt[1024];
int main()
{
string s;
cin >> s;
dp[0][0][0][0] = 1;
for (int i = 0; i < s.size(); i++)
{
for (int nz : {0, 1})
{
for (int ls : {0, 1})
{
for (int mask = 0; mask < (1 << 10); mask++)
{
for (char d = '0'; d <= '9'; d++)
{
if (d > s[i] && !ls)
continue;
int nmask = mask;
if (d != '0' || nz)
nmask |= (1 << (d - '0'));
dp[i + 1][nz | (d != '0')][ls | (d < s[i])][nmask] += dp[i][nz][ls][mask];
}
}
}
}
}
for (int mask = 0; mask < (1 << 10); mask++)
{
for (int nz : {0, 1})
{
for (int ls : {0, 1})
{
cnt[mask] += dp[s.size()][nz][ls][mask];
}
}
}
LL ans = 0;
for (int a = 1; a < (1 << 10); a++)
{
for (int b = 1; b < (1 << 10); b++)
{
if ((a & b) != 0)
ans += cnt[a] * cnt[b];
}
}
cout << ans << "\n";
return 0;
}