#include <bits/stdc++.h>
using namespace std;
long long s=1,n,num,num1=0,i,ans=0;
ifstream f1("bai4_17.inp");
ofstream f2("bai4_17.out");
string f(long a)
{
    long long d;
    string b[]={"0","1"};
    string s="";
    while(a>0)
    {
        d=a%2;
        if (d==1) num1++;
        s=b[d]+s;
        a=a/2;
    }
    num=s.length();
    return s;
}
int main()
{
    f1>>n;
    f2<<f(n)<<endl;
    for(i=1;i<=num1;i++){
        ans=ans+pow(2,num-i);
    }
    f2<<ans;
    f1.close();
    f2.close();
}
