#include #include #include constexpr int D = 9; void solve() { int n; std::cin >> n; int ans = 0; for (int b = 0; b < (1 << D * 2); ++b) { int c = b, x = 0; for (int i = 0; i < D; ++i) { x = x * 10 + (c % 4 * 3); c /= 4; } if (10 <= x && x <= n) ++ans; } for (int x = 12; x <= 99; x += 3) { if ((x % 10) % 3 == 0) continue; if (x <= n) ++ans; } std::cout << ans << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }