#include <bits/stdc++.h>
#define bug printf("************\n");
#define fuck(x) cout << #x << " -> " << x << endl
#define endl '\n'
#define int long long
using namespace std;
constexpr int N = 1e6 + 10, inf = 0x3f3f3f3f;
int arr[4] = {2, 0, 1, 9};
void solve()
{
int n;
cin >> n;
int sum = 0;
for (int i = 1; i <= n; i++)
{
int t = i;
bool flag = false;
while (t)
{
int u = t % 10;
for (int j = 0; j < 4; j++)
{
if (arr[j] == u)
{
sum += i;
flag = true;
break;
}
}
if (flag == true)
{
break;
}
t /= 10;
}
}
cout << sum << endl;
}
signed main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T = 1;
while (T--)
{
solve();
}
return 0;
}
06-12
1514
02-24
2038
09-18
6735
03-29
763
04-16
415
01-02
136