$$\Huge很简单的DFS$$
#include<bits/stdc++.h> using namespace std; int n,sum; void dfs(int x) { if(x>n) return; sum++; dfs(x*10); dfs(x*10+1); } int main() { cin>>n; dfs(1); cout<<sum; }