#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
string s;
while(cin >> s){
const int sz = s.size();
int cnt = pow(2,sz)-1;
for(int i = 0;i<sz;i++)
{
if(s[i]>'1')
break;
else if(s[i]=='0')
cnt -= pow(2,sz-i-1);
}
cout << cnt << endl;
}
return 0;
}