#include using namespace std; int ans, n; bool check(int n) { while (n) { int tmpn = n % 10; if (tmpn == 2 || tmpn == 0 || tmpn == 1 || tmpn == 9) return true; n /= 10; } return false; } int main() { cin >> n; for (int i = 1; i <= n; i++) { if (check(i)) ans += i; } cout << ans << endl; return 0; }