#include using namespace std; struct uns_t {} uns; template auto vec(Element init, Head arg, Args ...args) { if constexpr (sizeof...(Args) == 0) return std::vector(arg, init); else return std::vector(arg, vec(init, args...)); } template auto vec(uns_t, Head arg, Args ...args) { return vec(Element(), arg, args...); } int main() { constexpr int64_t base = 1000000001; int64_t n; cin >> n; map used; auto btoi = [](int bits) { int ans = 0; while (bits) { ans *= 10; ans += bits & 1; bits >>= 1; } return ans; }; int ans = 0; for (int i = 1; i < (1 << 9); ++i) { auto unit = btoi(i); if (used[unit]) continue; used[unit] = true; bool found = false; auto s = to_string(unit); auto beg1 = begin(s); auto beg2 = end(s) - 1; while (begin(s) != beg2 && end(s) != beg1) { if (*beg1 != *beg2) { found = true; } ++beg1; --beg2; } if (found) continue; for (int j = 1; j <= 9; ++j) { ans += base * j * unit <= n; } } cout << ans << endl; }