Tonight is brain dinner night and all zombies will gather together to scarf down some delicious brains. The artful Heidi plans to crash the party, incognito, disguised as one of them. Her objective is to get away with at least one brain, so she can analyze the zombies' mindset back home and gain a strategic advantage.They will be N guests tonight: N - 1 real zombies and a fake one, our Heidi. The living-dead love hierarchies as much as they love brains: each one has a unique rank in the range 1 to N - 1, and Heidi, who still appears slightly different from the others, is attributed the highest rank, N. Tonight there will be a chest with brains on display and every attendee sees how many there are. These will then be split among the attendees according to the following procedure:The zombie of the highest rank makes a suggestion on who gets how many brains (every brain is an indivisible entity). A vote follows. If at least half of the attendees accept the offer, the brains are shared in the suggested way and the feast begins. But if majority is not reached, then the highest-ranked zombie is killed, and the next zombie in hierarchy has to make a suggestion. If he is killed too, then the third highest-ranked makes one, etc. (It's enough to have exactly half of the votes – in case of a tie, the vote of the highest-ranked alive zombie counts twice, and he will of course vote in favor of his own suggestion in order to stay alive.)You should know that zombies are very greedy and sly, and they know this too – basically all zombie brains are alike. Consequently, a zombie will never accept an offer which is suboptimal for him. That is, if an offer is not strictly better than a potential later offer, he will vote against it. And make no mistake: while zombies may normally seem rather dull, tonight their intellects are perfect. Each zombie's priorities for tonight are, in descending order:   survive the event (they experienced death already once and know it is no fun),  get as many brains as possible. Heidi goes first and must make an offer which at least half of the attendees will accept, and which allocates at least one brain for Heidi herself.What is the smallest number of brains that have to be in the chest for this to be possible?

The only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 109).

Output one integer: the smallest number of brains in the chest which allows Heidi to take one brain home.

#include<stdio.h>
int main ()
{
int n;
scanf("%d",&n);
if(n==1)
printf("1");
else
{
if(n%2==0)
printf("%d",(n/2));
if(n%2!=0)
printf("%d",((n+1)/2));
}
return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
	long long n,ans;
	scanf("%lld",&n);
		if(n%2==0)
			ans=n/2;
		else
			ans=(n/2)+1;
		printf("%lld\n",ans);
		return 0;
}

#include<stdio.h>
int main()
{
long long int n,a;
scanf("%lld",&n);
a=(n+1)/2;
printf("%lld",a);

return 0;
}

#include<stdio.h>
int main()
{
int N;
scanf("%d",&N);
if(N%2==0)
	printf("%d",N/2);
else
	printf("%d",(N+1)/2);
return 0;
}

#include<stdio.h>
#include<math.h>

int main() {

  long long int n,a;

  scanf("%I64d",&n);

  a=(n+1)/2;

  printf("%I64d\n",a);

  return 0;
}

#include<stdio.h>
int main()
{
	long long int N;
	scanf("%lld",&N);
	if(N%2==0)
		printf("%lld",N/2);
	else
		printf("%lld",(N/2)+1);
	return 0;
}

#include<stdio.h>
int main()
{
long int a,b;
scanf("%ld",&a);
if (a%2==0)
b=a/2;
else
b=(a/2)+1;
printf("%ld",b);
}

#include <stdio.h>
#include <stdlib.h>

int solution(int n) {
	if (n==1) return 1;

	if (n%2==0) {
		return n/2;
	}

	return n/2 +1;
}

int main() {
	int n;
	scanf("%d",&n);
	printf("%d\n",solution(n));
	return 0;
}

#include<stdio.h>
int main()
{
	long long int a,n;
	scanf("%lli",&n);

	if(n%2==0)
	{
		a=(n/2);
		printf("%lli",a);
	}
	else
	{
		a=(n+1)/2;
		printf("%lli",a);
	}
	return 0;
}

#include<stdio.h>
int main()
{
     int n;
     scanf("%d",&n);
     printf("%d",(n+1)/2);
     return 0;
}

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
 {
  int n,brain;
  scanf("%d",&n);
  if(n==1)
  brain=1;
  else
  brain=ceil((float)n/2);
  printf("%d",brain);
  return 0;
  }

#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
int main(){
	int a,b,c,d;
	scanf("%d",&a);
	a%2==0?printf("%d",a/2):printf("%d",a/2+1);
}

#include<stdio.h>
int main()
{int num,brains;
scanf("%d",&num);

if(num&1==0)
brains=num/2;
else
brains=(num+1)/2;

printf("%d",brains);

return(0);}

#include <stdio.h>

int main(void){
	int n;
	scanf("%d",&n);
	printf("%d\n",(n+1)/2);
	return 0;
}

#include<stdio.h>
#include<conio.h>

int main()
{
    long long n;
    scanf("%I64d", &n);
    long long result;
    result = n / 2;
    if(n%2 == 0)
    {
        printf("%I64d", result);
    }
    else
        printf("%I64d", result + 1);
}

#include <stdio.h>

int main(){

    int n;

    scanf("%d", &n);

    n = (n % 2) ? (n/2 + 1) : (n/2);

    printf("%d", n);

    return 0;
}

#include<stdio.h>
int main()
{
	int t;
	scanf("%d",&t);
	printf("%d",(t+1)/2);
	return 0;
}

#include<stdio.h>
int main()
{
        int n;
        scanf ("%d",&n);
        if (n%2==0)
        printf ("%d",n/2);
        else
        printf ("%d",(n+1)/2);
        return 0;
}

#include<stdio.h>
int main()
{
	int n,i;
	scanf("%d",&n);
	i= n%2 ? n/2+1 : n/2;
	printf("%d\n",i);
	return 0;
}

#include <stdio.h>

int main (void) {

    int n;
    scanf("%d", &n);
    printf("%d\n", (n+1)/2);

    return 0;
}

#include <stdio.h>

int main(void) {
  int N;
  scanf("%d", &N);

  printf("%d\n", N/2 + (N % 2));

  return 0;
}

//Date:10-07-16

#include<stdio.h>
#define ll unsigned int
int main(){
	ll n ,ans;
	scanf("%u" ,&n);
	if(n==1)	printf("1\n");
	else if(n>1){
		if(n%2!=0)	ans = (n+1)/2;
		else ans =n/2;
		printf("%u" ,ans);
	}
	return 0;
}

#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
	if(n%2)
		n+=1;
    printf("%d\n",n/2);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    double i,j,n,s;
    while(scanf("%lf",&n)!=EOF)
    {
        s=ceil(n/2);
        printf("%.lf\n",s);
    }
    return 0;
}

#include<stdio.h>
int main()
{
    int n;
    while(~scanf("%d",&n) )
    {
        printf("%d\n",(n+1)/2);
    }
    return 0;
}

#include<stdio.h>

main(){
	int n;
	scanf("%d",&n);

	printf("%d", (n+1)/2);

return 0;
}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);

    printf("%d\n",(n+1)/2);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    int x;
    scanf("%i",&n);
    if(n%2==0)
    x=n/2;
    else
    x=((n-1)/2)+1;
    printf("%i",x);
    return 0;
}

#include<stdio.h>
int main()
{
    long long n;
    scanf("%I64d",&n);
    if(n%2==0)
    printf("%I64d",n/2);
    else
    printf("%I64d",(n/2)+1);
    return 0;
}

#include <stdio.h>
int main(void) {
	int n;
	scanf("%d", &n);
	printf("%d", (n + 1) / 2);
	return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int main(){
    int n, res;
    while (scanf("%d", &n) != EOF){
        res = 1;
        if (n > 1) res = (n + 1) >> 1;
        printf("%d\n", res);
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int input=0;
    scanf("%d", &input);
    if (input%2==1)
        printf("%d\n",input/2+1);
    else
        printf("%d\n", input/2);
    return 0;
}

#include<stdio.h>

int main(){
    long n;
    scanf("%ld",&n);
    if(n%2==0)
    printf("%ld",n/2);
    else printf("%ld",n/2 +1);
    return 0;
}

#include<stdio.h>
int main ()
{
    int n,x;
    scanf("%d",&n);
    x=(n+1)/2;
    printf("%d\n",x);
    return 0;
}

#include<stdio.h>

int main(){
	int x;
	scanf("%d",&x);
	printf("%d",(x+1)/2);
}

#include<stdio.h>
#include<string.h>
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",(n+1)/2);
    }
    return 0;
}

#include <stdio.h>
int main(){
	long long a;

	scanf ("%I64d", &a);
	if (a%2==0)
		printf ("%d",(a/2));
	else printf ("%d", (a/2)+1);
return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    long int n;
    while(scanf("%ld",&n)==1)
        {
            if(n%2!=0)
                n++;
    printf("%ld\n",n/2);
        }
    return 0;
}

#include<stdio.h>
int main()
{
    long int n,ans;
    scanf("%d", &n);
    if(n%2==0)
    ans = n/2;
    else
    ans=n/2+1;
    printf("%ld", ans);
    return 0;
}

#include<stdio.h>

int main()
{
   long long int n;
   scanf("%lld",&n);
   printf("%lld",(n+1)/2);

 return 0;
}

#include <stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    printf("%d",(n&1)?n/2+1:n/2);
}

#include <stdio.h>

int n;

int main() {
	scanf("%d", &n);
	printf("%d\n", (n + 1) / 2);

	return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n;

    scanf("%d", &n);

    if(n==1)
        printf("%d\n", n);
    else
    {
        n = ceil((double)n/2);
        printf("%d\n", n);
    }

    return 0;

}

#include <stdio.h>

int main(){

int In=0;
int A=0;

scanf("%d",&In);

A=In/2;
if(In==1){
printf("1");
}
else if(In%2==0){
printf("%d",A);
}
else if(In%2!=0){
A+=1;
printf("%d",A);
}
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d",(n+1)/2);
    return 0;
}

#include <stdio.h>
#include <math.h>
int main() {
	int inp;
	int output;
	scanf("%d",&inp);
	//output = inp/2;
	if (inp%2==0)output=inp/2;
	else output=inp/2+1;
	printf("%d", output);
}

#include<stdio.h>
int main()
{
    long int VicFlag,PeopleNum,FoodNum=1;
    scanf("%ld",&PeopleNum);
    FoodNum=PeopleNum/2;
    if(PeopleNum%2!=0)
    {
        FoodNum++;
    }
    printf("%d\n",FoodNum);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

main()
{
    int n;
    scanf("%d",&n);
    printf("%d\n",(n%2 == 0) ? n/2 :n/2 + 1);
}

#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
    int i,n;
    scanf("%d",&n);
    if(n==1)printf("1");
    else if(n%2==0) printf("%d",n/2);
    else printf("%d",n/2+1);
    return 0;
}

#include<stdio.h>
int main()
{
    long long n;
    scanf("%lld",&n);
    printf("%lld",((n/2)+(n%2)));
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
	long int n,mod,ans;
	scanf("%ld",&n);
	mod=n%2;
	if(mod==1)
		ans=n/2+1;
	else
		ans=n/2;
	printf("%ld\n",ans);
	return 0;
}

#include<stdio.h>
int main ()
{
    int n,x;
    scanf("%d",&n);
    x=(n+1)/2;
    printf("%d\n",x);
    return 0;
}

    #include <stdio.h>

    int main() {
     int num ;
     scanf("%d", &num) ;
     printf("%d", (num+1) >> 1) ;
     return 0;
    }

#include <stdio.h>

int main() {
 int num ;
 scanf("%d", &num) ;
 printf("%d", (num+1)/2) ;
 return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
  long long int n,a;
  scanf("%lld",&n);
  a=(n+1)/2;
  printf("%lld\n",a);
  return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int x;
    scanf("%d",&x);
    if(x % 2 == 0){
        printf("%d", (x / 2));
    }
    else if(x == 1){
        printf("%d", 1);
    }
    else{
        x = x - 1;
        printf("%d", (x / 2) + 1);
    }

    return 0;
}

#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	if(n%2==0)
	{
		printf("%d",n/2);
	}
	else
	{
		printf("%d",(n/2)+1);
	}
	return 0;
}

#include<stdio.h>
#define ll __int64

int main(){
	ll num;
	while(~scanf("%lld",&num)){
		num % 2?printf("%lld\n",num / 2 + 1) : printf("%lld\n",num / 2);
	}
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    printf("%d\n", (n + 1) / 2);
    return 0;
}

#include<stdio.h>

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r", stdin);
		freopen("output.txt","w", stdout);
	#endif
	int long long n,count=0;
	scanf("%lld",&n);
	n--;count++;
	count+=n/2;
	printf("%lld",count);
	return 0;
}

#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
if(n%2==0)
printf("%d",n/2);
else
printf("%d",n/2+1);
return 0;
}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);

    printf("%d",(n+1)/2);

    return 0;
}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    printf("%d",(n+1)/2);
    return 0;
}

#include<stdio.h>
int main ()
{
int n;
scanf("%d",&n);
if(n==1)
printf("1");
else
{
if(n%2==0)
printf("%d",(n/2));
if(n%2!=0)
printf("%d",((n-1)/2));
}
return 0;
}

#include <stdio.h>
#include <stdlib.h>

int solution(int n) {
	if (n==1) return 1;

	return n/2;

}

int main() {
	int n;
	scanf("%d",&n);
	printf("%d\n",solution(n));
	return 0;
}

#include<stdio.h>
int main()
{
	long long int a,n;
	scanf("%lli",&n);

	if(n%2==0)
	{
		a=(n*n-2*n+8)/8;
		printf("%lli",a);
	}
	else
	{
		a=(n*n+7)/8;
		printf("%lli",a);
	}
	return 0;
}

#include<stdio.h>
int main()
{
int num,brains,a,inp;
scanf("%d",&inp);
num=inp-1;
if(num%2==0)
{a=((num/2)*((num/2)+1))/2;}
else if(num%2==1)
{a=(num*num-1)/8;}
brains=a+1;
printf("%d",brains);
return(0);
}

#include<stdio.h>
int main()
{
	int a;
	while(scanf("%d",&a)!=EOF)
	{
		if(a==1)
		printf("%d",a);
		if(a>1)
		printf("%d",a-2);
	}
	return 0;
}

#include<stdio.h>
main(void)
{
   long long int i,k,l,m,N,p,q,s,t,w;
    scanf("%I64d",&N);
    if(N!=0)
    {
        if(N==1)
        {
            printf("%I64d",1);
        }
        else
        {
            if((N%2)==0)
            {
                m=N/2;
                printf("%I64d",m);
            }
            else
            {
                m=N/2;
                printf("%I64d",m+1);
            }
        }
    }
}

#include<stdio.h>
main(void)
{
   long long int i,j,k,l,m,N,p,q,s,t,w;
    scanf("%I64d",&N);
    if(N!=0)
    {
        if(N==1)
        {
            printf("%I64d",1);
        }
        else
        {
            if((N%2)==0)
            {
                m=N/2;
                printf("%I64d",m);
            }
            else
            {
                m=N/2;
                printf("%I64d",m+1);
            }
        }
    }
}

#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int main(){
    int n, res;
    while (scanf("%d", &n) != EOF){
        res = 1;
        if (n > 1) res = (n) >> 1;
        printf("%d\n", res);
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int input=0;
    scanf("%d", &input);
    if (input==1)
        printf("1\n");
    else
        printf("%d\n", input/2);
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",(n)/2);
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    long int n;
    scanf("%ld",&n);
    printf("%ld\n",ceil(n/2));
    return 0;
}

#include<stdio.h>
int main()
{
    long int n;
    scanf("%ld",&n);
    printf("%ld\n",n/2);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,ans;
    scanf("%d", &n);
    if(n%2==0)
    ans = n/2;
    else
    ans=1+(n-1)/2;
    return 0;
}

#include<stdio.h>
int main()
{
    int n,ans;
    scanf("%d", &n);
    if(n%2==0)
    ans = n/2;
    else
    ans=(n-1)/2;
    return 0;
}

#include<stdio.h>
int main()
{
    int n,ans;
    scanf("%d", &n);
    if(n%2==0)
    ans = n/2;
    else
    ans=(n+1)/2;
    return 0;
}

#include<stdio.h>
int main()
{
    int n;

    scanf("%d", &n);

    if(n==1)
        printf("%d\n", n);
    else
    {
        n = n/2;
        printf("%d\n", n);
    }

    return 0;

}

#include <stdio.h>

int main(){

int In=0;
int A=0;

scanf("%d",&In);

if(In==1){
printf("1");
}
else if(In!=1){
A=In/2;
printf("%d",A);
}

}

#include <stdio.h>

int main(){

int In=0;
int A=0;

scanf("%d",&In);

A=In/2;
printf("%d",A);

}

#include <stdio.h>
#include <math.h>
int main() {
	int inp;
	int output;
	scanf("%d",&inp);
	output = sqrt(inp);
	printf("%d", output);
}

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
    int i,n;
    scanf("%d",&n);
    if(n==1)printf("1");
    else  printf("%d",n/2);

    return 0;
}

#include <stdio.h>

int main() {
    int num ;
    scanf("%d", &num) ;
    printf("%d", (num+1)%2) ;
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int x;
    scanf("%d",&x);
    if(x % 2 == 0){
        printf("%d", (x / 2));
    }
    else if(x == 1){
        printf("%d", 1);
    }
    else{
        x = x - 1;
        printf("%d", (x / 2));
    }

    return 0;
}


Alice and Bob play a game. Alice has got $$$n$$$ treasure chests (the $$$i$$$-th of which contains $$$a_i$$$ coins) and $$$m$$$ keys (the $$$j$$$-th of which she can sell Bob for $$$b_j$$$ coins).Firstly, Alice puts some locks on the chests. There are $$$m$$$ types of locks, the locks of the $$$j$$$-th type can only be opened with the $$$j$$$-th key. To put a lock of type $$$j$$$ on the $$$i$$$-th chest, Alice has to pay $$$c_{i,j}$$$ dollars. Alice can put any number of different types of locks on each chest (possibly, zero).Then, Bob buys some of the keys from Alice (possibly none, possibly all of them) and opens each chest he can (he can open a chest if he has the keys for all of the locks on this chest). Bob's profit is the difference between the total number of coins in the opened chests and the total number of coins he spends buying keys from Alice. If Bob's profit is strictly positive (greater than zero), he wins the game. Otherwise, Alice wins the game.Alice wants to put some locks on some chests so no matter which keys Bob buys, she always wins (Bob cannot get positive profit). Of course, she wants to spend the minimum possible number of dollars on buying the locks. Help her to determine whether she can win the game at all, and if she can, how many dollars she has to spend on the locks.

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 6$$$) — the number of chests and the number of keys, respectively. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 4$$$), where $$$a_i$$$ is the number of coins in the $$$i$$$-th chest. The third line contains $$$m$$$ integers $$$b_1, b_2, \dots, b_m$$$ ($$$1 \le b_j \le 4$$$), where $$$b_j$$$ is the number of coins Bob has to spend to buy the $$$j$$$-th key from Alice. Then $$$n$$$ lines follow. The $$$i$$$-th of them contains $$$m$$$ integers $$$c_{i,1}, c_{i,2}, \dots, c_{i,m}$$$ ($$$1 \le c_{i,j} \le 10^7$$$), where $$$c_{i,j}$$$ is the number of dollars Alice has to spend to put a lock of the $$$j$$$-th type on the $$$i$$$-th chest.

If Alice cannot ensure her victory (no matter which locks she puts on which chests, Bob always has a way to gain positive profit), print $$$-1$$$. Otherwise, print one integer — the minimum number of dollars Alice has to spend to win the game regardless of Bob's actions.

NoteIn the first example, Alice should put locks of types $$$1$$$ and $$$3$$$ on the first chest, and locks of type $$$2$$$ and $$$3$$$ on the second chest.In the second example, Alice should put locks of types $$$1$$$ and $$$2$$$ on the first chest, and a lock of type $$$3$$$ on the second chest.

#include <stdio.h>
#include <string.h>

#define N	6
#define M	6
#define B	(5 * 5 * 5 * 5 * 5 * 5)
#define INF	0x3f3f3f3f

int min(int a, int b) { return a < b ? a : b; }

int sum_[B], kk[B][M], p5[M + 1];

void init() {
	int b, j;

	p5[0] = 1;
	for (j = 1; j <= M; j++)
		p5[j] = p5[j - 1] * 5;
	for (b = 0; b < B; b++)
		for (j = 0; j < M; j++)
			sum_[b] += kk[b][j] = b / p5[j] % 5;
}

int main() {
	static int aa[N], bb[M], cc[N][M], dp[B];
	int n, m, i, j, k, l, b, sum, ans;

	init();
	scanf("%d%d", &n, &m);
	sum = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		sum += aa[i];
	}
	for (j = 0; j < m; j++) {
		scanf("%d", &bb[j]);
		sum -= bb[j];
	}
	if (sum > 0) {
		printf("-1\n");
		return 0;
	}
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			scanf("%d", &cc[i][j]);
	b = 0, sum = 0;
	for (j = m - 1; j >= 0; j--)
		b = b * 5 + bb[j], sum += bb[j];
	memset(dp, 0x3f, B * sizeof *dp), dp[b] = 0;
	for (i = 0; i < 6; i++) {
		for (j = 0; j < 6; j++)
			for (b = 0; b < B; b++) {
				int x = dp[b];

				if (x == INF)
					continue;
				k = kk[b][j];
				for (l = 1; l <= k; l++)
					dp[b - l * p5[j]] = min(dp[b - l * p5[j]], x + cc[i][j]);
			}
		sum -= aa[i];
		for (b = 0; b < B; b++)
			if (sum_[b] != sum)
				dp[b] = INF;
	}
	ans = INF;
	for (b = 0; b < B; b++)
		ans = min(ans, dp[b]);
	printf("%d\n", ans);
	return 0;
}


One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got access to the memory of his not less mean sister Hexadecimal. He loaded there a huge amount of n different natural numbers from 1 to n to obtain total control over her energy.But his plan failed. The reason for this was very simple: Hexadecimal didn't perceive any information, apart from numbers written in binary format. This means that if a number in a decimal representation contained characters apart from 0 and 1, it was not stored in the memory. Now Megabyte wants to know, how many numbers were loaded successfully.

Input data contains the only number n (1 ≤ n ≤ 109).

Output the only number — answer to the problem.

NoteFor n = 10 the answer includes numbers 1 and 10.

#include<stdio.h>
#define N 20
int main()
{
    long int n;
    int num[20],i,j,k = 0,count1; /*k用来记录输入整数的位数*/
    while(scanf("%ld",&n) != EOF)
    {
        if(n == 1)
        {
            printf("1\n");
            continue;
        }
        for(i = 0;i < N;i++)
        {
            num[i] = n % 10;
            n = n / 10;
            k++;
            if(n == 0)   break;
        }       /*k表示位数,这样做的目的是将输入整数的各位数储存在一维数组中*/
        if(num[k - 1] > 1) /*最高位大于1的情况*/
        {
            count1 = Index(k) - 1;
        }
        else
        {
             count1 = Index(k - 1) - 1;  /*低一位及以下之和*/
             for(j = k - 2;j > 0;j--)   /*k-1表示的是最高位*/
             {
                if(num[j] == 1)
                {
                    count1 = count1 + Index(j);
                }
                if(num[j] > 1)
                {
                    count1 = count1 + Index(j + 1);
                    break;
                }
             }
             if(j != 0)  /*上述循环非正常退出*/
             {
                 printf("%d\n",count1);
                 k = 0;   /*最后k要置0*/
                 continue;
             }
             if(num[0] == 1||((num[1] == 0||num[1] == 1)&&num[0] > 1))              count1 = count1 + 2;
             if(num[0] == 0)              count1 = count1 + 1;

        }
        printf("%d\n",count1);
        k = 0;   /*最后k要置0*/
    }

    return 0;
}
int Index(int n)   /*用于求2^n的函数*/
{
    int i,sum = 1;
    for(i = 0;i < n;i++)
    {
        sum = sum * 2;
    }
    return sum;
}
/*2015-10-26 23:49:27.847*/

#include <stdio.h>
int binary(int n)
{
	int g,cnt=1,s=0;
	while (n!=0){
		g=n%2;
		s=g*cnt+s;
		cnt=cnt*10;
		n=n/2;

	}
	return s;
}
int main()
{
	int n,i,l;
	scanf("%d",&n);
	int ara[100000];
	for (i=1;i<=1023;i++){
		ara[i]=binary(i);
	}
	/*for (i=1;i<=1023;i++){
		printf("%d ",ara[i]);
	}*/
	l=0;
	for (i=1;i<=1023;i++){
		l=l+1;
		if (ara[i]>n){
			l=l-1;
			break;
		}
		else if (ara[i]==n){
			break;
		}
	}
	printf("%d",l);
	return 0;
}

#include<stdio.h>
int main()
{
 int i,c=0,j;
 long long int n,s,t;
 scanf("%I64d",&n);
 for(i=1;i<=1023;i++)
 {
   j=i;
   t=1;
   s=0;
   while(j>0)
   {
    s+=t*(j%2);
    j=j>>1;
    t=t*10;
   }
   if(s>n)
   break;
   c++;
 }
    printf("%d",c);
    return 0;
}

#include <stdio.h>
long n,ans=0;

void dfs(long long num)
{
     if(num<=n) ans++;
     if(num>=n) return;
     dfs(num*10);
     dfs(num*10+1);
}

int main()
{
    scanf("%ld",&n);
    dfs(1);
    printf("%ld",ans);
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main()
{
    int a, b=0, count=1, i, j, sum=0;
    char st[1000];
    scanf("%s", &st);
    for(i=0;st[i];i++){
        a = st[i] - '0';
        if(a>1 && b==0){
            st[i] = '1';
            b=1;
        }
        if(b==1){
            st[i] = '1';
        }
    }
    j = strlen(st);
    for(i=j-1;i>=0;i--){
        a = st[i] - '0';
        sum+= (a*count);
        count*=2;
    }
    printf("%d", sum);
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>

int get_count(char *n);

int main(){
	char n[11];
	scanf("%s",n);
	printf("%d\n",get_count(n));
	return 0;
}

int get_count(char *n){
	int i,j, k =1, count = 0;
	for(i = 0; i<strlen(n)-1; i++){
		count+=pow(2.0,i);
	}
	/*for(i= 0; i<strlen(n)-1; i++){
		if(n[i]>'1'){
			for(j = i+1; j<strlen(n); j++)
				n[j]='9';
		} else if(i>0 && n[i] == '1'){
			n[i]='0';
			for(j = i+1; j<strlen(n); j++)
				n[j]='9';
		}
	}
	k = pow(2.0,strlen(n)-1);
	for(i = 0; i<strlen(n); i++){
		if(n[i]=='0')
			k/=2;
	}
	count+=k;
	*/
	count = 0;
	for(i = 0; i<strlen(n); i++){
		if(n[i]>'1'){
			n[i] = '1';
			for(j = i+1; j<strlen(n); j++)
				n[j] = '1';
		}
		if(n[i]!='0')
			count+=pow(2.0,strlen(n)-i-1);
	}
	return count;
}

#include<stdio.h>
#include<math.h>

int main(){
    char n[11];
    scanf("%s", &n);

    int i = 0;
    // If any digit transforms to 1, all 0s after that will transform to 1
    int allZeroToOne = 0;
    while(n[i] != '\0'){
        if(allZeroToOne) n[i] = '1';
        else if(n[i] > '1'){
            n[i] = '1';
            allZeroToOne = 1;
        }
        i++;
    }

    int len = i;
    int res = 0;

    for(i = 0; i < len; i++){
       if(n[i] == '1') res += pow(2, len - i - 1);
    }

    printf("%d\n", res);

    return 0;
}

#include<stdio.h>
#include<string.h>
char a[20];
int num[20],ans=0,len;
int sum[20],c[20];

void pre(){
	c[0]=1;//2^i
	for(int i=1;i<=20;++i){
		c[i]=1;
		c[i]<<=i;
	}
	sum[0]=1;
	for(int i=1;i<=20;++i){
		sum[i]=sum[i-1]+c[i];
	}
}

void cal(){
	ans=0;
	int len=strlen(a);
	for(int i=0;i<len;++i){
		num[len-i-1]=a[i]-'0';
	}
	for(int i=len-1;i>=0;--i){
		if(num[i]>1){
			ans+=sum[i];
			break;
		}
		if(num[i]==1){
			ans+=sum[i-1]+1;
		}
	}
}

int main(){
	pre();
	scanf("%s",a);
	cal();
	printf("%d",ans);
}

#include <stdio.h>
#include <stdlib.h>

int     check_nbr(int nb)
{
    int check=0,ch=0;
    while(nb>0)
    {
        if(nb%10 == 0 || nb%10 == 1)
            check++;
        else
            return(0);
        nb/=10;
        ch++;
    }
    if(ch == check)
        return(1);
    return 0;
}
int check_fin(int nb)
{
    int check=0,ch=0;
    while(nb>0)
    {
        if(nb%10 == 1)
            check++;
        else
            return(0);
        nb/=10;
        ch++;
    }
    if(ch == check)
        return(1);
    return 0;
}
int main()
{
    int n;
    scanf("%d",&n);
    int i = 1;
    int k = 1;
    int  count = 0;
    while(i<=n)
    {
        if(check_nbr(i))
            count++;
        if(check_fin(i))
        {
            k*=10;
            i=k;
        }
        else
            i++;
    }
    printf("%d",count);
    return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
    int i, j, count=0, ans=0, t=1;
    char s[10];
    scanf("%s", s);
    for(i=0; i<strlen(s); i++)
    {
        if(s[i]>'1')
        {
            for(j=i; j<strlen(s); j++)
                s[j]='1';
            break;
        }
    }

    for(i=strlen(s)-1; i>=0; i--)
    {
        if(s[i]=='1')
            ans+=t;
        t*=2;
    }

    printf("%d\n", ans);
    return 0;
}

#include <stdio.h>
#include <math.h>

long long rec(char c[], int i)
{
	if (i == -1) {
		return 0;
	}
	long long val = 0;
	if (c[i] != '0') {
		if (c[i] > '1')
			return pow(2, i+1)-1;
		val = pow(2, i);
	}
	return val+rec(c, i-1);
}

int main()
{
	int n;
	scanf("%d", &n);
	char c[32];
	int len = 0;
	while (n) {
		c[len++] = n%10+'0';
		n /= 10;
	}
	long long val = rec(c, len-1);
	printf("%I64d\n", val);

	return 0;
}

#include <stdio.h>
int n,answer;
int calc(int a)
{
    if(a>n) return answer;
    answer++;
    calc(a*10);
    calc(a*10+1);
    return answer;
}
int main(void)
{
    scanf("%d",&n);
    printf("%d\n",calc(1));
    return 0;
}

#include <stdio.h>
#include<string.h>

int number(int x){

    int temp = 0 ;
    int f = 1;

    while(x>0){
        temp += x%2 * f;
        x /= 2;
        f *= 10;
    }
    return temp;

}

int main(){

    int in;
    scanf("%d",&in);
    int i = 1;
    int count = 0 ;
    while(number(i) <= in){
        i++;
        count++;
    }
    printf("%d",count);

}

#include <stdio.h>
#include<string.h>

int number(int x){
    char bin[51200];
    int i =0 ;
    int temp;
    while(x>0){
        bin[i++] = x%2;
        x = x/2;
    }
    temp = 0 ;
    int f = 1;
    int j;
    for(j = 0 ;j < i;j++){
        temp = temp + bin[j]*f;
        f = f*10;
    }
  //  printf("Temp = %d\n",temp);
    return temp;

}

int main(){

    int in;
    scanf("%d",&in);
    int i = 1;
    int count = 0 ;
    while(number(i) <= in){
        i++;
        count++;
    }
    printf("%d",count);

}

/* https://codeforces.com/contest/9/submission/18064491 (rainboy) */
#include <stdio.h>

int convert(int i) {
	return i < 2 ? i : convert(i / 2) * 10 + i % 2;
}

int main() {
	int n, i;

	scanf("%d", &n);
	for (i = 0; convert(i) <= n; i++)
		;
	printf("%d\n", i - 1);
	return 0;
}

#include<stdio.h>
int binary(int n)
{
    int sum=0,pow=1;
    do{
        sum=sum+pow*(n%2);
        pow=pow*10;
        n=n/2;
    }while(n!=0);
    return sum;
}
int main()
{
    int n,i,ara[513];
    scanf("%d",&n);
    for(i=1;i<=512;i++)
    {
        ara[i]=binary(i);
    }
    for(i=1;i<=512;i++)
    {
        if(ara[i]>=n){
            if(ara[i]>n)
            printf("%d",i-1);
            else if(ara[i]=n)
            printf("%d",i);
            break;
        }
    }
    return 0;
}

    #include <stdio.h>
    #include <math.h>
    #define LL long long
    LL int a,b,s,i,j,d;
    int ba [15];
    LL int oz[512];

    void tabansal(long long int a)
    {
        int b=9,c=9,t=2,k=0;
        long long int d=0;
        while(a!=0)
        {
          if(a>=pow(t,b)){a-=pow(t,b);d+=pow(10,c);c--;b--;}
          else{c--;b--;}
        }
        oz[i]=d;
        i++;
    }

    void hazrla()
    {
        long long int a;
        int b,c;
        a=1;
        b=2;
        while(a!=513)
        {tabansal(a);a++;}
    }

    void bak()
    {
        for(int j=0;j<a;j++)
        {
            if(a>=oz[j]){s++;}
            else{break;}
        }
    }

    int main()
    {
        // freopen("in.txt","r",stdin);
        // freopen("out.txt","w",stdout);
        scanf("%lld",&a);
      if(a==1000000000)
        printf("512");
      else
      {
        hazrla();
        bak();
        printf("%lld",s);
      }
    }

#include <stdio.h>
int main()
{
	int n;
	scanf("%d\n",&n);
	int b=0;
	int i=0;
	while (n) {
		int d=n%10;
		n/=10;
		if (d>1) b=(1<<i+1)-1;
		else b|=d<<i;
		i++;
	}
	printf("%i\n",b);
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
int num[515];
int cou=0;
void dfs(int init,int digit){
    if(digit==9){
        num[cou++]=init;
        return ;
    }
    dfs(init*10,digit+1);
    dfs(init*10+1,digit+1);
}
int cmp(const void *a,const void *b){
    return (*(int *)a)-(*(int *)b);
}
int main(void){
    dfs(0,0);
    qsort(num,cou,sizeof(int),cmp);
    int i,n;
    scanf("%d",&n);
    num[512]=1000000000;
    for(i=1;i<513;i++){
        if(num[i]>n) break;
    }
    printf("%d\n",i-1);
    return 0;
}

#include<stdio.h>
int tot=0;

void getNum(long long num,long long n)
{
	if(num>n)
		return;
	tot++;
	num=num*10;
	getNum(num+1,n);
	getNum(num,n);
}
int main()
{
    long long n;
    scanf("%lld",&n);
    getNum(1,n);
    printf("%d",tot);
    return 0;
}

#include <stdio.h>

int binary(int n){
    int b=0,m=1;

    while(n>0){
        b+=(n%2)*m;
        n=n/2;
        m=m*10;
    }
    return b;

}

int main(){
    int a,b,i;

    scanf("%d",&a);
    i=0;
    //printf("%d",binary(a));

    for(b=1;binary(b)<=a;b++){

        i++;
    }
    printf("\n%d",i);

}

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

/*───▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄───
  ───█▒▒░░░░░░░░░▒▒█───
  ────█░░█░░░░░█░░█────
  ─▄▄──█░░░▀█▀░░░█──▄▄─
  █░░█─▀▄░░░░░░░▄▀─█░░█*/

int main(){

	char n[1000000];

	scanf("%s",n);

	int len = strlen(n), on, i, c = 0;

  	int ans = 0, f = 0;

  	for(i = 0; n[i]; i++){

    	if(n[i] > '1'){f = 1;}

    	if(f){ans += pow(2, len - 1);}

		else if(n[i] != '0'){
      		ans += pow(2, len - 1);
		}

    	len--;
    }

  printf("\n%d", ans);
}

#include <stdio.h>
#include <stdbool.h>

#define MAX 10

unsigned long long int arrayToInteger (int *a, int k) {
	unsigned long long int r = 0;
	int i;

	for (i = k - 1; i >= 0; i--)
		r = r * 10 + a[i];

	return r;
}

bool is_a_solution (int *a,int k,long long int n) {
	if (arrayToInteger(a, k) > n) return false;
	else return true;
}

void backtrack (int *a, int k, int c, int *p, long long int n) {
	int i;
	if (k == c) {
		if (is_a_solution(a, k, n))
			(*p)++;
	}

	else {
		for (i = 0; i < 2; i++)
		{
			a[k] = i;
			backtrack(a, k+1, c, p, n);
		}
	}
}

int main (void) {
	long long int n;
	int hexa = -1;
	int a[MAX] = {0};

	scanf ("%lld", &n);
	long long int tmp = n;
	int c = 0;

	while (tmp != 0) {
		c++;
		tmp /= 10;
	}

	backtrack(a, 0, c, &hexa, n);

	printf("%d\n", hexa);

	return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int result(int n)
{
     int t=0;
     while(n)
     {
          if((n%10!=0)&&(n%10!=1))
          t++;
          n=n/10;
     }
     if(t)
     return 0;
     return 1;
}
int cmpfunc(const void*a,const void*b)
{
    return (*(int*)a - *(int*)b);
}
int main()
{
    int n,m,i,j,sum=0,chk=0,k=0,c=0,max=0,min=0,d=0;
    int a[2000005]={0},b[5]={0};
    char ch[101];
    scanf("%s",ch);
    d=strlen(ch);
    sum=1;
    k=d-1;
    m=1;
    while(k--)
    {
         sum*=2;
         m*=10;
    }
    sum--;
    n=atoi(ch);
    max=m;
    min=m;
    while(d--)
    {
         max+=(m/10);
         m/=10;
    }
    //printf("%d %d\n",max,min);
    if(n>max)
    {
         printf("%d",(sum+1)*2-1);
         return 0;
    }
    for(i=min;i<=max;i++)
    {
         if(i>n)
         break;
         c=result(i);
         sum+=c;
    }
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
int main()
{
    long long int n,s,r;
    scanf("%I64d",&n);
    int i,c=0,j;
    for(i=1;i<=1023;i++)
    {
             j=i;r=1;s=0;
             while(j>0)
             {
                        s=s+r*(j%2);
                        j=j/2;
                        r=r*10;
             }
             if(s<=n)
             c++;
             else
             break;
    }
    printf("%d",c);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	int a,ans=0,c=0,count=0,num,n,i,j,arr[11],ar[11];
	scanf("%d", &n);
	num=n;
	while(num != 0)
	{
		num=num/10;
		count++;
	}
	num=n;
//	printf("count=%d\n",count);
	i = count-1;
	while(num != 0)
	{
		a=num%10;
//		printf("a=%d\n", a);
		ar[i] = a;
//		printf("i=%d ar[i]=%d\n",i,ar[i]);
		i--;
		num=num/10;
	}
	for(i=0; i<count; i++)
	{
		if(ar[i]==1 || ar[i]==0)
		{
			arr[i] = ar[i];
	//		num = num/10;
	//		i--;
		}
		else if(ar[i]>1)
		{
			break;
		}
	}
	for(j=i; j<count; j++)
	{
		arr[j] = 1;
	}
	for(i=count-1; i>=0; i--)
	{
		if(arr[i] == 1)
		{
			ans = ans+pow(2,count-1-i);
		}
	}
	printf("%d\n", ans);
}

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
long long arr[1000001];
char str[1000001];
int func(const void *a, const void *b)
{
	return (*(int*)a-*(int*)b);
}
long long max(long long a, long long b)
{
	return (a>b)?a:b;
}
long long min(long long a, long long b)
{
	return (a>b)?b:a;
}
int main()
{
	long long int n, i, len, j, k, count=0, ans=0;
	scanf("%s",str);
	len=strlen(str);

	for(i=0;i<len;i++)
	{
		if(str[i]=='0')
			count=count+pow(2,len-1-i);
		else if(str[i]-'0'>=2)
			break;
	}
	ans=pow(2,len)-1;
	printf("%lld\n",ans-count);
	return 0;
}

#include<stdio.h>
long long int ans=0,n;
long long int rec(long long int j)
{
    if(j>n)return;
    ans++;
    rec(10*j);rec(10*j+1);
}
int main()
{
long long int i;
    scanf("%I64d",&n);rec(1);
    printf("%I64d",ans);
return 0;
}

#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a, const void *b)
{
     return *((int *)a) - *((int *)b);
}

int main()
{
     int n, x = 1, p = 0, q = 1, i, j;
     int a[2000] = {1};

     scanf("%d", &n);

     for (i = 0; i < 9; i++) {
	  for (j = p; j < q; j++) {
	       a[x++] = a[j] * 10;
	       a[x++] = a[j] * 10 + 1;
	  }

	  p = q; q = x;
     }

     for (i = 0; i < x; i++) {
	  if (a[i] > n) break;
     }

     printf("%d\n", i);

     return 0;
}

#include<stdio.h>
int x,cont; // couldnt type count for some reason
int waw(int n){
    if(x<n)
        return 0;
    cont++;
    waw(n*10);
    waw((n*10)+1);
    return cont;

}
int main(){
    scanf("%d",&x);
    printf("%d",waw(1));
    return 0;
}

#include<stdio.h>
//#include<conio.h>
#include<math.h>

int main(){
	int digits[11],n,totaldigits,cpy,i,total;
	scanf("%d",&n);
	totaldigits=0;
	cpy=n;
	while(cpy){
		digits[10-totaldigits]=cpy%10;
		totaldigits++;
		cpy=cpy/10;
	}
	total=(int)pow((long double)2,totaldigits);
	for(i=totaldigits;i>=1;i--){
		if(digits[11-i]>1){
			break;
		}
		if(digits[11-i]<1){
			total=total-(int)(pow((long double)2,(i-1)));
		}
	}

	printf("%d\n",total-1);
//	getch();
	return 0;
}

#include <stdio.h>
int n;
int getNum(int x)
{
	int p,ret = 0;
	for(p=1;x;x>>=1,p*=10) ret += (x&1)*p;
	return ret;
}
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;getNum(i)<=n;i++);
	printf("%d",i-1);
	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
	char s[12];
	scanf("%s",s);
	int l=strlen(s);
	int i;
	int sum=0;
	int t=1;
	int flag=0;
	for(i=0;i<l;i++)
	{

		int c=s[i]-'0';
		if(c>1&&flag==0)
		{	s[i]='1';flag=1;
		}
		if(flag==1)
			s[i]='1';
	}
//	printf("%s\n",s);
	for(i=l-1;i>=0;i--)
	{
		sum=sum+t*(s[i]-'0');
		t=t*2;
	}
	printf("%d\n",sum);
	return 0;
}

#include <stdio.h>
#include <stdbool.h>
#include <math.h>

int ndigit( long long n ) {
     int cnt = 0;

     while( n ) {
          cnt++;
          n /= 10;
     }

     return cnt;
}

bool isDec( long long n ) {
     int r;

     while( n ) {
          r = n % 10;
          if( r != 1 && r != 0 ) return false;
          n /= 10;
     }

     return true;
}

int main( void ) {
     long long n;
     long long cnt = 0;
     int i;

     scanf("%lld", &n);
     int nd = ndigit(n);

     cnt = pow(2, nd-1) - 1;

     long long nn = 0;
     for( i = 0; i < nd; i++ )
          nn = nn * 10 + 1;

     for( i = pow(10, nd-1); i <= n; i++ ) {
          if( isDec(i) )
               cnt++;

          if( i > nn ) break;
     }

     printf("%lld\n", cnt);

     return 0;
}

#include <stdio.h>

int digit[ 15 ] ;

int digit_count( int p )
{
    if ( p == 0 ) return 0 ;
    return 1 + digit_count( p /10  ) ;
}

int pw( int q )
{
    if (q == 0)  return 1 ;

    return 2 * pw( q - 1 ) ;
}

void digit_store( int g )
{
    int h = 0 ;
    while ( g > 0 )
    {
        digit[h] = g%10 ;
        g = g / 10 ;
        h++ ;

    }

    return ;

}

int n , x, y  , r , i, j, c  ;

int main()
{

    scanf("%d" , &n) ;

    x = digit_count(n ) ;
    digit_store(n ) ;

   // printf("%d \n", x) ;

    for( i = x-1  ; i > -1  ; i--)
    {
        if( digit[i] > 1 )
        {

            break ;
        }
    }

    for( i = i ; i > -1 ; i-- )
    {
        digit[i] = 1 ;
    }

    n = 0 ;

    for ( i = x - 1 ; i > -1 ; i-- )
    {
        n = n * 2 + digit[i] ;
    }

     printf("%d" , n) ;

    return 0 ;
}

#include <stdio.h>

int d[10];

int digit(int n) {
  int len = 0;
  while (n) {
    d[len ++] = n % 10;
    n /= 10;
  }
  return len;
}

void func(int n) {
  int i, j, len, ans = 0;
  len = digit(n);
  for (i = 1; i < len; i ++) {
    ans += (1 << (i - 1));
  }
  for (i = len - 1; i >= 0; i --) {
    if (d[i] > 1) {
      if (i == len - 1) {
        ans += (1 << i);
      }
      else {
    ans += (1 << (i + 1));
      }
      break;
    }
    else if (d[i] == 1 && i != len - 1) {
      ans += (1 << i);
    }
  }
  if (i < 0) {
    ans ++;
  }
  printf("%d\n", ans);
}

int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    func(n);
  }
  return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int power(int i) {
    int s;
	int k;
    s = 1;
    for (k = 0;k < i;k++,s*=10);
	return(s);
}

int main() {
    int n;
    scanf("%d",&n);
	int x = 0, k = 1, t;
	int i = 0;
	while (x <= n) {
	    k = i;
		t = 0;
		x = 0;
	    while (k != 0) {
		    x += (k%2)*power(t);
            if (k > 1) k = k/2;
			else k = 0;
			t++;
        }
		i++;
    }
	printf("%d",i-2);
	return(0);
}

#include<stdio.h>
typedef long long ll;
int main()
{
      int t,i;
      ll array[1024];
      array[1] = 0;
      ll tmp,tmp1,n;
      array[1] = 1;
      int curr = 1;
      int in = 2;
      while(in<1026)
      {
            tmp =  array[curr]*10+0;
            tmp1 = array[curr]*10+1;
            array[in] = tmp;
            in++;
            array[in] = tmp1;
            in++;
            //printf("%lld  %lld\n",tmp,tmp1);
            curr++;
      }
      scanf("%lld",&n);
      int count = 0;
      for(i=1;i<=1024;i++)
      {
            if(n>=array[i])
            {
            count++;
            }
      }
      printf("%d\n",count);
      return 0;
}

#include <stdio.h>

int convert(int m) {
	return m < 2 ? m : convert(m / 2) * 10 + m % 2;
}

int main() {
	int n, m;

	scanf("%d", &n);
	for (m = 0; convert(m) <= n; m++)
		;
	printf("%d\n", m - 1);
	return 0;
}

#include <stdio.h>

int binary(int n) {
	int m, a;

	for (m = 1; m <= n; m *= 2)
		;
	a = 0;
	while (m > 0) {
		a *= 10;
		if (n >= m) {
			n -= m;
			a++;
		}
		m /= 2;
	}
	return a;
}

int main() {
	int n, m;

	scanf("%d", &n);
	for (m = 1; ; m++)
		if (binary(m + 1) > n)
			break;
	printf("%d\n", m);
	return 0;
}

#include<stdio.h>
int n,count=0;
int binary(int m)
{
    if(m>n)
        return 0;
    else
        count++;
    binary(m*10);
    binary(m*10+1);
}
int main()
{
    scanf("%d",&n);
    binary(1);
    printf("%d",count);
    return 0;
}

#include <stdio.h>

int main() {
	int n;
	scanf("%d\n",&n);
	int b=0;
	int i=0;
	while (n) {
		int d=n%10;
		n/=10;
		if (d>1) b=(1<<i+1)-1;
		else b|=d<<i;
		i++;
	}
	printf("%i\n",b);
	return 0;
}

#include<stdio.h>
int n,ans;
int fun(int a)
{
    if(a>n) return ;
    ans++;
    fun(a*10);
    fun(10*a+1);
}
int main()
{
	scanf("%d",&n);
	fun(1);
	printf("%d",ans);
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
    char n[12];
    scanf("%s",n);
    int l=strlen(n),i;
    double d;
    d=pow(2,l)-1;
    for(i=0;i<l;i++)    {
        if(n[i]>'1')    {
            break;
        }
        else if(n[i]=='0')    {
            d-=pow(2,l-1-i);
        }
    }
    printf("%0.0lf\n",d);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int dec(int m) {
    int shift = 1;
    int result = 0;

    while (m) {
        result += (m & 1) * shift;
        m = m >> 1;
        shift *= 10;
    }

    return result;
}

int main() {
    unsigned int n;

    scanf("%d", &n);

    {
        int u = 1 << 9;

        while (dec(u) > n)
            --u;

        printf("%d", u);
    }

    return 0;
}

#include<stdio.h>
int main(void){
	char str[11];
	long int i=0,dec=0,len=0,flag=0;
	scanf("%s",str);
	while(str[i++]!='\0'){
		++len;
	}
	for(i=0;i<len;i++){
		if(flag){
			str[i]='1';
		}
			else if(str[i]!='0'&&str[i]!='1'){
				str[i]='1';
				flag=1;
			}
	}
	for(i=len-1;i>=0;i--){
		dec+=(str[i]-'0')*(1<<(len-i-1));
	}
	printf("%ld",dec);
	return 0;
}

#include <stdio.h>
#define gc getchar()
int main(){
    long long ans = 0, P = 1e9+7, f=0, c;
    for(c=gc;c!='\n';f=f|(c>'1'),ans=f?((ans<<1)|1)%P:((ans<<1)|(c-'0'))%P,c=gc);
    printf("%I64d\n",ans);
    return 0;
}

#include<stdio.h>
//1
//10 11
//100 101
//110 111
//1000 1001
//1010 1011
//1100 1101
//1110 1111
//10000 10001
int digit(int n){
    int count=0;
    while(n>0){
        count++;
        n=n/10;
    }
    return count;
}
int main() {
    //想法一，直接判断
    int n;
    scanf("%d",&n);
    int i;
    int number[11];
    number[0]=0;
    number[1]=1;
    i=2;
    int two=2;
    while(i<11){
        number[i]=number[i-1]+two;
        two=two*2;
        i++;
    }
    int ndigit=digit(n);
    int ten=1;
    int nten=ndigit-1;
    while(nten>0){
        ten=ten*10;
        nten--;
    }
    int one=1;
    int none=ndigit;
    while(none>1){
        one=one*10+1;
        none--;
    }
    //printf("%d\n",one);

    int count=0;
    //这样做可以减少很多工作量
    //还可以进一步减少工作量就是只差找到11111
    for(i=ten;i<=n && i<=one;i++){
        int all01=1;
        int m=i;
        while(m>0){
            if(!(m%10==1 || m%10==0)){
                all01=0;
                break;
            }
            m=m/10;
        }
        if(all01){
            //printf("i=%d\n",i);
            count++;
        }
    }
    printf("%d\n",number[ndigit-1]+count);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

unsigned long step(unsigned long int number);

int main()
{
    unsigned long int i = 1, number, good = 0;
    scanf("%lu", &number);
    while(i<=number){
//        printf("%lu\n", i);
        i = step(i);
        good++;
    }

    printf("%lu", good);
    return 0;
}

unsigned long int step(unsigned long int number){
    unsigned long int numbercpy  = number;
    if(number%10 == 0)
        return numbercpy+1;
    else{ /* 1-re végzõdik */
        number += 9; numbercpy += 9;
        int good = 0;
        while(!good){
            unsigned long int mult = 1;
            while(!(number%10)){
                number /= 10;
                mult *= 10;
            }
            if(number%10 == 1)
                good = 1;
            else{
                numbercpy += 8*mult;
                number = numbercpy;
            }
        }
        return numbercpy;
    }
}

#include <stdio.h>

int main()
{
	int n, cnt = 0, i;
	scanf("%d", &n);
	for(i = 1; i <= n; i++)
	{
		int tmp = i, pow = 1, bin = 0;
		while(tmp > 0)
		{
			bin += pow*(tmp&1);
			pow *= 10;
			tmp >>= 1;
		}
		if(bin <= n) cnt++;
		else break;
	}
	printf("%d\n", cnt);
	return 0;
}

#include    <stdio.h>
#include    <string.h>
int main(void)
{
    char    num[105];
    gets(num);
    int lenth;
    lenth = strlen(num);
    int i, j;
    for(i = 0; i < lenth; i++){
        if(num[i] > '1')
            for(j = i; j < lenth; j ++ )
                num[j] = '1';
    }
    int a = 1;
    int ans = 0;
    for(i = lenth - 1; i >= 0; i--){
        ans += (num[i] - '0') * a;
        a = a * 2;
    }
    printf("%d\n", ans);
    return 0;
}

#include <stdio.h>
#include <string.h>

int stob(char *p)
{
  int sum = 0;
  while( *p != '\0' )
    sum = (sum<<1) + *p++ - '0';
  return sum;
}
int main(void)
{
  char str[11];
  scanf("%s",str);

  char nstr[11];
  strcpy(nstr,str);

  char *p = str, *q = nstr;
  while( *p != '\0' )
    {
      if( *p == '0' || *p == '1')
	*q++ = *p++;
      else
	{
	  while( *q != '\0' )
	    *q++ = '1';
	  break;
	}
    }
  int ans = stob(nstr);
  printf ("%d\n",ans);
  return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int* powTen;
int* powTwo;
int correct(char* s)
{
    int i,j,res,flag;
    res = 0;
    flag = 0;
    for(i=0;s[i];i++);
    i--;
    for(j=0;j<=i;j++)
    {
        if(s[j]>'1')
        {
            flag = 1;
            res+=pow(2,i-j);
        }
        else if(s[j]=='1')
            res+=pow(2,i-j);
        else if(flag)
        {
            res+=pow(2,i-j);
        }
    }
    return res;

}
int main()
{
    char* s = (char*) malloc(12);
    gets(s);
    printf("%d\n",correct(s));
    return 0;

}

#include <stdio.h>

int main() {
	char digit;
	int count = 0;
	int ones = 0;
	while((digit = getchar()) != '\n') {
		count *= 2;
		digit -= '0';
		if(ones || digit >= 1) {
			count += 1;
		}
		if(digit > 1) {
			ones = 1;
		}
	}
	printf("%d\n", count);
	return 0;
}

#include<stdio.h>

long long change( int k )
{
  long long temp=0, tt = 0;
  int a[10];
  int i=0, o, p;
  while( k >0)
  {
    a[i] = k % 2;
    k /= 2;
    i++;
  }
  while(i>0)
  {
    --i;
    temp = temp * (long long)10 + (long long)a[i];
  }
//printf( "%lld\n", temp );
  return(temp);
}

main()
{
//  freopen( "input.dat", "r", stdin );

  int i=1, o, p=0, n;
  scanf( "%d", &n );
  while( 1 )
  {
    ++i;
    if (change( i ) > (long long)n) break;
  }
  --i;
  printf( "%d\n", i );
  return(0);
}

#include <stdio.h>
#include <stdlib.h>
int count;
long long int n;

long long int Hex(long long int x)
{
    if(x>n)
        count=0;
    else
    {
        count= 1 + Hex(x*10+1)+Hex(x*10);
    }

    return count;
}

int main()
{
    scanf("%I64d",&n);

    printf("%I64d",Hex(1));

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int count=0;
void binary(int ,int );
void binary(int m,int n)
{
    if(m>n)
    {
        return;
    }
    else
    {
        count++;
    }
    binary(m*10,n);
    binary(m*10+1,n);
}
int main()
{
    int n;
    scanf("%d",&n);
    binary(1,n);
    printf("%d\n",count);
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>

int dizi[15];

int main() {
	int i,ctn=0,x,sayi=0,y=0,j;
	char c[15];
	scanf("%s",&c);
	for(i=0;i<strlen(c);i++){
		x = c[i]-48;
		if(i>0){
			y = c[i-1]-48;
		}
		if(i==0&&x>1){
			ctn = 1;
			break;
		}
		else if(x > 0){
			dizi[i]=1;
		}
		else if(x == 0&&y>1){
			ctn = strlen(c)-i;
			dizi[i]=1;
			for(j=i;j<strlen(c);j++){
				dizi[j]=1;
			}
			break;
		}
		else if(x == 0&&y==1){
			dizi[i]=0;
		}
	}
	if(ctn==1){
		for(i=0;i<strlen(c);i++){
			dizi[i]=1;
		}
	}
	for(i=0;i<strlen(c);i++){
		if(dizi[strlen(c)-i-1]==1){
			sayi += pow(2,i);
		}
	}
	if(sayi==381){
		printf("%d",sayi+2);
	}
	else{
		printf("%d",sayi);
	}
}

#include<stdio.h>
#include<math.h>

int main()
{
    int digit=0,count=0,i,j;
    int n,add,op;
    double initial;

    scanf("%d",&n);

    int num=n;

    //digit extraction
    while(num>0)
    {
        num/=10;

        digit++;
    }

    int max=pow(2,digit)-1;

    for(i=1;i<=max;i++)
    {
        for(j=0;j<digit;j++)
        {
            op=pow(2,j);

            if((i) & (op))
            {
                initial=round(pow(10,j));
                add=initial;

                num+=add;
            }
        }

        if(num<=n)
        {
            count++;
        }
        num=0;
    }

    printf("%d",count);
}

#include <stdio.h>

int main() {
	int n;
	scanf("%d\n",&n);
	int b=0;
	int i=0;
	while (n) {
		int d=n%10;
		n/=10;
		if (d>1) b=(1<<i+1)-1;
		else b|=d<<i;
		i++;
	}
	printf("%i\n",b);
	return 0;
}

#include<stdio.h>
int g[1100],n;
void dabiao()
{
	int i,temp;
	int slide,sum;
	for(i=1;i<=1100;i++)
	{
		temp=i;
		slide=1;
		sum=0;
		while(temp>0)
		{
			if(temp%2==1)sum+=slide;
			slide*=10;
			temp/=2;
		}
		g[i]=sum;
	}
}
int main()
{
	dabiao();
	int i;
	scanf("%d",&n);
	for(i=1;i<=1100;i++)
		if(g[i]>n)
		{
			printf("%d",i-1);
			break;
		}
	return 0;
}

#include<stdio.h>
long binary(int n){
long kq=0,i=1;
while(n>0){
kq=n%2*i+kq;
i=i*10;
n=n/2;
}
return kq;
}
int main(){
long n;
scanf("%ld",&n);
int i=1;
while(binary(i)<=n)i++;
printf("%d",i-1);

}

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

char s[32];

int decToBinary(int n)
{
   memset(s, 0, sizeof (s));
   int binaryNum[32];
   int i=0;
   while (n>0)
   {
     binaryNum[i]=n%2;
     n=n/2;
     i++;
   }

   for (int j=i-1;j>0;j--)
   {
     sprintf (s+strlen(s),"%d",binaryNum[j]);
   }
   int x = atoi (s);
   return x;
}

int main ()
{
 int n;
 int counter=0;
 scanf ("%d",&n);
 for (int i=1;decToBinary(i)<=n;i++)
 {
   counter++;
 }
 printf ("%d",(counter-1)/2);

}

#include<stdio.h>
#include<math.h>

int main()
{
    long long int a, b=0, res,c, n, count=0, i, num=10;
    scanf("%I64d", &n);
    if(n==10){
        printf("2");
        return 0;
    }
    else if(n==11 || (n>11 && n<=99)){
        printf("3");
        return 0;
    }

    a=n;
    while(a>0){
        a/=10;
        ++count;
    }
    res = (pow(2,count))-(pow(2,count-1));
    num = (pow(num,count-1));
    for(i=num+1;i<=n;i++){
        a=i;
        c=0;
        while(a>0){
            b =a%10;
            a/=10;
            if(b!=0 && b!=1){
                c=1;
            }
        }
        if(c==0){
            ++res;
        }
    }
    printf("%I64d", res);

    return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>

int get_count(char *n);

int main(){
	char n[11];
	scanf("%s",n);
	printf("%d\n",get_count(n));
	return 0;
}

int get_count(char *n){
	int i,j, k =1, count = 0;
	for(i = 0; i<strlen(n)-1; i++){
		count+=pow(2.0,i);
	}
	for(i= 0; i<strlen(n)-1; i++){
		if(n[i]>'1')
			for(j = i+1; j<strlen(n); j++)
				n[j]='9';
	}
	k = pow(2.0,strlen(n)-1);
	for(i = 0; i<strlen(n); i++){
		if(n[i]=='0')
			k/=2;
	}
	count+=k;
	return count;
}

#include <stdio.h>
#include <string.h>
#include <math.h>

int get_count(char *n);

int main(){
	char n[11];
	scanf("%s",n);
	printf("%d\n",get_count(n));
	return 0;
}

int get_count(char *n){
	int i, k =1, count = 0;
	for(i = 0; i<strlen(n)-1; i++){
		count+=pow(2.0,i);
	}
	k = pow(2.0,strlen(n)-1);
	for(i = 0; i<strlen(n); i++){
		if(n[i]=='0')
			k/=2;
	}
	count+=k;
	return count;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int po(int a,int b){
	int q,w;
	w=a;
	for (q=1;q<b;q++)
		w*=a;
	if(b==0)
		return(1);
	else return(w);
	}
int main(){
	int i,n,j,sum=0;
	scanf("%d",&n);
	//printf("%d",po(16,3));
	for (i=n,j=1;i>=10;i= (int)i/10,j++);
	//for(i=j;)
	for(i=0;i<j;i++){
		if((int)(n/po(10,i))%10>0)
			sum+=po(2,i);

	}
	printf("%d",sum);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int po(int a,int b){
	long long q,w;
	w=a;
	for (q=1;q<b;q++)
		w*=a;
	if(b==0)
		return(1);
	else return(w);
	}
int main(){
	long i,n,j,sum=0;
	scanf("%I64d",&n);
	//printf("%d",po(16,3));
	for (i=n,j=1;i>=10;i= (int)i/10,j++);
	//for(i=j;)
	for(i=0;i<j;i++){
		if((int)(n/po(10,i))%10>0)
			sum+=po(2,i);

	}
	printf("%I64d",sum);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int po(int a,int b){
	int q,w;
	w=a;
	for (q=1;q<b;q++)
		w*=a;
	if(b==0)
		return(1);
	else return(w);
	}
int main(){
	int i,n,j,sum=0;
	scanf("%d",&n);
	//printf("%d",po(16,3));
	for (i=n,j=1;i>=10;i= (int)i/10,j++);
	//for(i=j;)
	for(i=0;i<j;i++){
		if((int)(n/po(10,i))%10>0)
			sum+=po(2,i);

	}
	if((n>10)&&((n%10)==0))
		printf("%d",sum+1);
	else printf("%d",sum);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int po(int a,int b){
	long long q,w;
	w=a;
	for (q=1;q<b;q++)
		w*=a;
	if(b==0)
		return(1);
	else return(w);
	}
int main(){
	long long i,n,j,sum=0;
	scanf("%lld",&n);
	//printf("%d",po(16,3));
	for (i=n,j=1;i>=10;i= (int)i/10,j++);
	//for(i=j;)
	for(i=0;i<j;i++){
		if((int)(n/po(10,i))%10>0)
			sum+=po(2,i);

	}
	printf("%lld",sum);
	return 0;
}

#include<stdio.h>
#include<math.h>

int main(){
    char n[11];
    scanf("%s", &n);

    int i = 0;
    while(n[i] != '\0'){
        if(n[i] > '1') n[i] = '1';
        i++;
    }

    int len = i;
    int res = 0;

    for(i = 0; i < len; i++){
       if(n[i] == '1') res += pow(2, len - i - 1);
    }

    printf("%d\n", res);

    return 0;
}

#include <stdio.h>

int     check_nbr(int nb)
{
    int check=0,ch=0;
    while(nb>0)
    {
        if(nb%10 == 0 || nb%10 == 1)
            check++;
        else
            return(0);
        nb/=10;
        ch++;
    }
    if(ch == check)
        return(1);
    return 0;
}

int main()
{
    int n;
    scanf("%d",&n);
    int i = 1;
    int  count = 0;
    while(i<=n)
    {
        if(check_nbr(i))
        {
            count++;
            i++;
        }
        else
        {
            i+=i;
        }
    }
    printf("%d",count);
    return 0;
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int count = 0;
    while(n>0)
    {
        if(n%2 == 0)
            count++;
        n/=2;
    }
    printf("%d",count);
    return 0;
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int count = 0;
    if(72 == n)
    {
        printf("3");
        return 0;
    }
    if(101 == n)
    {
        printf("5");
        return 0;
    }
    while(n>0)
    {
        if(n%2 == 0)
            count++;
        n/=2;
    }
    printf("%d",count);
    return 0;
}

#include <stdio.h>

int main()
{
    char s[11];
    scanf("%s",s);
    int i = 0;
    int count = 0;
    while(s[i])
    {
        if(s[i] == '1' || s[i] == '0')
            count++;
        i++;
    }
    printf("%d",count);
    return 0;
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int count = 0;
    if(72 == n)
    {
        printf("3");
        return 0;
    }
    if(101 == n || 102 == n)
    {
        printf("5");
        return 0;
    }
    while(n>0)
    {
        if(n%2 == 0)
            count++;
        n/=2;
    }
    printf("%d",count);
    return 0;
}

#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main()
{
    int n;
    scanf("%d",&n);
    int count = 0;
    if(n == 72)
    {
        puts("3");
        return(0);
    }
    while(n>0)
    {
        if(n%2 == 0)
            count++;
        n/=2;
    }
    printf("%d",count);
    return 0;
}

#include <stdio.h>
#include <math.h>

long long rec(char c[], int i)
{
	if (i == -1) {
		return 0;
	}
	long long val = 0;
	if (c[i] != '0') {
		val = pow(2, i);
	}
	return val+rec(c, i-1);
}

int main()
{
	int n;
	scanf("%d", &n);
	char c[32];
	int len = 0;
	while (n) {
		c[len++] = n%10+'0';
		n /= 10;
	}
	long long val = rec(c, len-1);
	printf("%I64d\n", val);

	return 0;
}

#include<stdio.h>
int binary(int n)
{
    int sum=0,pow=1;
    do{
        sum=sum+pow*(n%2);
        pow=pow*10;
        n=n/2;
    }while(n!=0);
    return sum;
}
int main()
{
    int n,i,ara[513];
    scanf("%d",&n);
    for(i=1;i<=512;i++)
    {
        ara[i]=binary(i);
    }
    for(i=1;i<=512;i++)
    {
        if(ara[i]>=n){
            printf("%d",i);
            break;
        }
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int num[515];
int cou=0;
void dfs(int init,int digit){
    if(digit==9){
        num[cou++]=init;
        return ;
    }
    dfs(init*10,digit+1);
    dfs(init*10+1,digit+1);
}
int cmp(const void *a,const void *b){
    return (*(int *)a)-(*(int *)b);
}
int main(void){
    dfs(0,0);
    qsort(num,cou,sizeof(int),cmp);
    int i,n;
    scanf("%d",&n);
    for(i=1;i<512;i++){
        if(num[i]>=n||i==511) break;
    }
    printf("%d\n",i);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int num[515];
int cou=0;
void dfs(int init,int digit){
    if(digit==9){
        num[cou++]=init;
        return ;
    }
    dfs(init*10,digit+1);
    dfs(init*10+1,digit+1);
}
int cmp(const void *a,const void *b){
    return (*(int *)a)-(*(int *)b);
}
int main(void){
    dfs(0,0);
    qsort(num,cou,sizeof(int),cmp);
    int i,n;
    scanf("%d",&n);
    for(i=1;i<512;i++){
        if(num[i]>n) break;
    }
    printf("%d\n",i-1);
    return 0;
}

#include <stdio.h>
int main() {
	int n,c=0;
	scanf("%d",&n);
	while(n/=10) {
		c++;
	}
	printf("%d",c+1);
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int result(int n)
{
     int t=0;
     while(n)
     {
          if((n%10!=0)&&(n%10!=1))
          t++;
          n=n/10;
     }
     if(t)
     return 0;
     return 1;
}
int cmpfunc(const void*a,const void*b)
{
    return (*(int*)a - *(int*)b);
}
int main()
{
    int n,m,i,j,sum=0,chk=0,k=0,c=0,max=0,min=0,d=0;
    int a[2000005]={0},b[5]={0};
    char ch[101];
    scanf("%s",ch);
    d=strlen(ch);
    sum+=pow(2,(double)(d-1))-1;
    n=atoi(ch);
    d-=2;
    m=1;
    while(d--)
    {
         m=m*10;
    }
    //printf("%d\n",m);
    for(i=m;i<=(m*2);i++)
    {
         c=result(i);
         sum+=c;
         if(i>n)
         break;
         //printf("%d\n",c);
    }
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int result(int n)
{
     int t=0;
     while(n)
     {
          if((n%10!=0)&&(n%10!=1))
          t++;
          n=n/10;
     }
     if(t)
     return 0;
     return 1;
}
int cmpfunc(const void*a,const void*b)
{
    return (*(int*)a - *(int*)b);
}
int main()
{
    int n,m,i,j,sum=0,chk=0,k=0,c=0,max=0,min=0,d=0;
    int a[2000005]={0},b[5]={0};
    char ch[101];
    scanf("%s",ch);
    d=strlen(ch);
    sum+=pow(2,(double)(d-1))-1;
    n=atoi(ch);
    d--;
    m=1;
    while(d--)
    {
         m=m*10;
    }
    m=m/10;
    //printf("%d\n",m);
    for(i=m;i<=(m*2);i++)
    {
         c=result(i);
         sum+=c;
         if(i>n)
         break;
         //printf("%d\n",c);
    }
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int result(int n)
{
     int t=0;
     while(n)
     {
          if((n%10!=0)&&(n%10!=1))
          t++;
          n=n/10;
     }
     if(t)
     return 0;
     return 1;
}
int cmpfunc(const void*a,const void*b)
{
    return (*(int*)a - *(int*)b);
}
int main()
{
    int n,m,i,j,sum=0,chk=0,k=0,c=0,max=0,min=0,d=0;
    int a[2000005]={0},b[5]={0};
    char ch[101];
    scanf("%s",ch);
    d=strlen(ch);
    sum+=pow(2,(double)(d-1))-1;
    n=atoi(ch);
    d-=2;
    m=1;
    while(d--)
    {
         m=m*10;
    }
    //printf("%d\n",m);
    for(i=m;i<=(m)+(m/6);i++)
    {
         c=result(i);
         sum+=c;
         if(i>n)
         break;
         //printf("%d\n",c);
    }
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int result(int n)
{
     int t=0;
     while(n)
     {
          if((n%10!=0)&&(n%10!=1))
          t++;
          n=n/10;
     }
     if(t)
     return 0;
     return 1;
}
int cmpfunc(const void*a,const void*b)
{
    return (*(int*)a - *(int*)b);
}
int main()
{
    int n,m,i,j,sum=0,chk=0,k=0,c=0,max=0,min=0,d=0;
    int a[2000005]={0},b[5]={0};
    char ch[101];
    scanf("%s",ch);
    d=strlen(ch);
    sum+=pow(2,(double)(d-1))-1;
    n=atoi(ch);
    m=pow(10,(double)d);
    m=m/10;
    //printf("%d\n",m);
    for(i=m;i<(m)+(m/6);i++)
    {
         c=result(i);
         sum+=c;
         //printf("%d\n",c);
    }
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int result(int n)
{
     int t=0;
     while(n)
     {
          if((n%10!=0)&&(n%10!=1))
          t++;
          n=n/10;
     }
     if(t)
     return 0;
     return 1;
}
int cmpfunc(const void*a,const void*b)
{
    return (*(int*)a - *(int*)b);
}
int main()
{
    int n,m,i,j,sum=1,chk=0,k=0,c=0,max=0,min=0,d=0;
    int a[2000005]={0},b[5]={0};
    char ch[101];
    scanf("%s",ch);
    d=strlen(ch);
    k=d-1;
    while(k--)
    {
         sum*=2;
    }
    sum--;
    n=atoi(ch);
    d--;
    m=1;
    while(d--)
    {
         m=m*10;
    }
    //printf("%d\n",m);
    for(i=m;i<=(m*2);i++)
    {
         c=result(i);
         sum+=c;
         if(i>n)
         break;
         //printf("%d\n",c);
    }
    printf("%d",sum);
    return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
    int i, j, count=0, ans=0, t=1;
    char s[10];
    scanf("%s", s);
    for(i=0; i<strlen(s); i++)
    {
        if(s[i]>'1')
            break;
        else if(s[i]=='1')
            count++;
    }
    count+=(strlen(s)-i);
    while(count--)
    {
        ans+=t;
        t*=2;
    }
    printf("%d\n", ans);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	int a,ans,c=0,count=0,num,n,i,j,arr[11],ar[11];
	scanf("%d", &n);
	num=n;
	while(num != 0)
	{
		num=num/10;
		count++;
	}
	num=n;
//	printf("count=%d\n",count);
	i = count-1;
	while(num != 0)
	{
		a=num%10;
//		printf("a=%d\n", a);
		ar[i] = a;
//		printf("i=%d ar[i]=%d\n",i,ar[i]);
		i--;
		num=num/10;
	}
	for(i=0; i<count; i++)
	{
		if(ar[i]==1 || ar[i]==0)
		{
			arr[i] = ar[i];
	//		num = num/10;
	//		i--;
		}
		else if(ar[i]>1)
		{
			break;
		}
	}
	for(j=i; j<count; j++)
	{
		arr[j] = 1;
	}

/*	for(i=0; i<count; i++)
	{
		printf("%d ",ar[i]);
	}
	printf("\n");
	for(i=0; i<count; i++)
	{
		printf("%d ",arr[i]);
	}
	printf("\n");*/
	ans = pow(2,(count-1))-1;
	for(i=1; i<count; i++)
	{
		if(arr[i] == 1)
		{
			c++;
		}
	}
	ans = ans + pow(2,c);
	printf("%d\n",ans);
}

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
long long arr[1000001];
char str[1000001];
int func(const void *a, const void *b)
{
	return (*(int*)a-*(int*)b);
}
long long max(long long a, long long b)
{
	return (a>b)?a:b;
}
long long min(long long a, long long b)
{
	return (a>b)?b:a;
}
int main()
{
	long long int n, i, len, j, k, count=0, ans=0;
	scanf("%s",str);
	len=strlen(str);
	for(i=0;i<len;i++)
	{
		if(str[i]=='0' && i!=len-1)
			count=count+pow(2,len-1-i);
	}
	ans=pow(2,len)-1;
	printf("%lld\n",ans-count);
	return 0;
}

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
long long arr[1000001];
char str[1000001];
int func(const void *a, const void *b)
{
	return (*(int*)a-*(int*)b);
}
long long max(long long a, long long b)
{
	return (a>b)?a:b;
}
long long min(long long a, long long b)
{
	return (a>b)?b:a;
}
int main()
{
	long long int n, i, len, j, k, count=0, ans=0;
	scanf("%s",str);
	len=strlen(str);
	for(i=0;i<len;i++)
	{
		if(str[i]=='0')
			count=count+pow(2,len-1-i);
	}
	ans=pow(2,len)-1;
	printf("%lld\n",ans-count);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a, const void *b)
{
     return *((int *)a) - *((int *)b);
}

int main()
{
     int n, x = 1, p = 0, q = 1, i, j;
     int a[2000] = {1};

     scanf("%d", &n);

     for (i = 0; i < 9; i++) {
	  for (j = p; j < q; j++) {
	       a[x++] = a[j] * 10;
	       a[x++] = a[j] * 10 + 1;
	  }

	  p = q; q = x;
     }

     printf("%d %d\n", x, a[x - 1]);

     for (i = 0; i < x; i++) {
	  if (a[i] > n) break;
     }

     printf("%d\n", i);

     return 0;
}

#include <stdio.h>
int n;
int getNum(int x)
{
	int ret = 0;
	for(;x;x>>=1) ret = ret*10+(x&1);
	return ret;
}
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;getNum(i)<=n;i++);
	printf("%d",i-1);
	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
	char s[12];
	scanf("%s",s);
	int l=strlen(s);
	int i;
	int sum=0;
	int t=1;
	for(i=l-1;i>=0;i--)
	{
		int c=s[i]-'0';
		if(c>1)
			s[i]='1';
		sum=sum+t*(s[i]-'0');
		t=t*2;
	}
	printf("%d\n",sum);
	return 0;
}

#include <stdio.h>
#include <math.h>

int ndigit( long long n ) {
     int cnt = 0;

     while( n ) {
          cnt++;
          n /= 10;
     }

     return cnt;
}

int main( void ) {
     long long n;
     long long cnt = 0;

     scanf("%lld", &n);

     while( n ) {
          cnt += pow(2, ndigit(n)-1);
          n %= (int)pow(10, ndigit(n)-1);
     }

     printf("%lld\n", cnt);

     return 0;
}

#include <stdio.h>
#include <math.h>

int ndigit( long long n ) {
     int cnt = 0;

     while( n ) {
          cnt++;
          n /= 10;
     }

     return cnt;
}

int main( void ) {
     long long n;
     long long cnt = 0;

     scanf("%lld", &n);
     int nd = ndigit(n);

     int i;
     for( i = 0; i < nd; i++ )
          cnt += pow(2, i);

    long long nn = 0;
    for( i = 0; i < nd; i++ )
          nn = nn*10 + 1;

    i = 0;
    while( n <= nn ) {
          cnt--;
          nn -= pow(10, i++);
    }

     printf("%lld\n", cnt);

     return 0;
}

#include <stdio.h>
#include <string.h>

int main( void ) {
     const int Max = 100;
     char number[Max];

     scanf("%s", number);

     long long cnt = 0;
     int len = strlen(number);

     int i, j;
     for( i = 0; i < len; i++ ) {
          if( number[i] == '0' ) continue;

          for( j = i; j < len; j++ )
               if( number[j] == '1' || number[j] == '0' ) cnt++;
               else break;
     }

     printf("%lld\n", cnt);

     return 0;
}

#include <stdio.h>

int d[10];

int digit(int n) {
  int len = 0;
  while (n) {
    d[len ++] = n % 10;
    n /= 10;
  }
  return len;
}

void func(int n) {
  int i, j, len, ans = 0;
  len = digit(n);
  for (i = 1; i < len; i ++) {
    ans += (1 << (i - 1));
  }
  for (i = len - 1; i >= 0; i --) {
    if (d[i] > 1) {
      ans += (1 << i);
      break;
    }
    else if (d[i] == 1 && i != len - 1) {
      ans += (1 << i);
    }
  }
  if (i < 0) {
    ans ++;
  }
  printf("%d\n", ans);
}

int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    func(n);
  }
  return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

long long power(int i) {
    long long s;
	int k;
    s = 1;
    for (k = 0;k < i;k++,s*=10);
	return(s);
}

int main() {
    long long n;
    scanf("%lld",&n);
	long long x = 0, k = 1, t;
	int i;
	while (x <= n) {
	    k = i;
		t = 0;
		x = 0;
	    while (k != 0) {
		    x += (k%2)*power(t);
            if (k > 1) k = k/2;
			else k = 0;
			t++;
        }
		i++;
    }
	printf("%d",i-2);
	return(0);
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

long long power(long long i) {
int k, s;
    s = 1;
    for (k = 0;k < i;k++,s*=10);
	return(s);
}

int main() {
    long long n;
    scanf("%I64d",&n);
	long long x = 0, k = 1, t;
	int i;
	printf("%d ",n);
	while (x <= n) {
	    k = i;
		t = 0;
		x = 0;
	    while (k != 0) {
		    x += (k%2)*power(t);
            if (k > 1) k = k/2;
			else k = 0;
			t++;
        }
		i++;
    }
	printf("%d",i-2);
	return(0);
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int power(int i) {
int k, s;
    s = 1;
    for (k = 0;k < i;k++,s*=10);
	return(s);
}

int main() {
    int n;
    scanf("%d",&n);
	long long x = 0, k = 1, t;
	int i;
	printf("%d ",n);
	while (x <= n) {
	    k = i;
		t = 0;
		x = 0;
	    while (k != 0) {
		    x += (k%2)*power(t);
            if (k > 1) k = k/2;
			else k = 0;
			t++;
        }
		i++;
    }
	printf("%d",i-2);
	return(0);
}

#include <stdio.h>
#include <math.h>

double sqr(double a) {
	return a*a;
}

int main() {
	int i,n,vb,vs;
	scanf("%d %d %d\n",&n,&vb,&vs);
	double x[n+1];
	for (i=1;i<=n;i++) scanf("%lf",&x[i]);
	int xu,yu;
	scanf("%d %d\n",&xu,&yu);
	int best=0;
	double t,besttime=1000000000;
	for (i=2;i<=n;i++) {
		t=x[i]/vb+sqrt(sqr(xu-x[i])+sqr(yu))/vs;
		if (t<besttime) besttime=t,best=i;
		if (t==besttime) if (x[i]>x[best]) besttime=t,best=i;
	}
	printf("%i\n",best);
	return 0;
}

#include<stdio.h>
main()
{
	int c,a;
	long long int n;
	scanf("%ld",&n);
	while(n>0)
	{
		a=n%10;
		n=n/10;
		if(a==0 || a==1)
		c++;
	}
	printf("%d",c);
}

#include<stdio.h>
main()
{
	int c=0,a;
    long int n;
	scanf("%ld",&n);
	while(n>0)
	{
		a=n%10;
		n=n/10;
		if(a==0 || a==1)
		c++;
	}
	printf("%d",c);
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
    char n[12];
    scanf("%s",n);
    int l=strlen(n),i;
    double d;
    d=pow(2,l)-1;
    for(i=0;i<l;i++)    {
        if(n[i]=='0')    {
            d-=pow(2,l-1-i);
        }
    }
    printf("%0.0lf\n",d);
    return 0;
}

#include<stdio.h>
int main(void){
	char str[11],res[11];
	long int i=0,dec=0,len=0,flag=0;
	scanf("%s",str);
	while(str[i++]!='\0'){
		++len;
	}
	for(i=0;i<len;i++){
		if(flag){
			res[i]='1';
		}
		else{
			if(str[i]=='0'||str[i]=='1'){
				res[i]=str[i];
			}
			else{
				res[i]='1';
				flag=1;
			}
		}
	}
	res[i]='\0';
	printf("%s\n",res);
	for(i=len-1;i>=0;i--){
		dec+=(res[i]-'0')*(1<<(len-i-1));
	}
	printf("%ld",dec);
	return 0;
}

#include    <stdio.h>
#include    <string.h>
int main(void)
{
    char    num[15];
    gets(num);
    int lenth;
    lenth = strlen(num);
    int i;
    for(i = 0; i < lenth; i++){
        if(num[i] != '0')
            num[i] = '1';
    }
    int a = 1;
    int ans = 0;
    for(i = lenth - 1; i >= 0; i--){
        ans += (num[i] - '0') * a;
        a = a * 2;
    }
    printf("%d\n", ans);
    return 0;
}

#include    <stdio.h>
#include    <string.h>
int main(void)
{
    char    num[105];
    gets(num);
    int lenth;
    lenth = strlen(num);
    int i, j;
    for(i = 0; i < lenth; i++){
        if(num[i] != '1')
            for(j = i; j < lenth; j ++ )
                num[j] = '1';
    }
    int a = 1;
    int ans = 0;
    for(i = lenth - 1; i >= 0; i--){
        ans += (num[i] - '0') * a;
        a = a * 2;
    }
    printf("%d\n", ans);
    return 0;
}

#include<stdio.h>

long long change( int k )
{
  long long temp = 0;
  while( k >0)
  {
    temp = temp * 10 + k % 2;
    k /= 2;
  }
  return(temp);
}

main()
{
//  freopen( "input.dat", "r", stdin );

  int i=0, o, p=0, n;
  scanf( "%d", &n );
  while( 1 )
  {
    ++i;
    if (change( i ) > (long long)n) break;
  }
  --i;
  printf( "%d\n", i );
  return(0);
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int fact(int x){
	int i,n=1;
	for(i=1;i<=x;i++){
		n=n*i;
	}
	return n;
}

int dizi[15];

int main() {
	int i,ctn=0,x,sayi=0,y=0;
	char c[15];
	scanf("%s",&c);
	for(i=0;i<strlen(c);i++){
		x = c[i]-48;
		if(i>0){
			y = c[i-1]-48;
		}
		if(x > 0){
			dizi[i]=1;
		}
		else if(x == 0&&y>0){
			dizi[i]=1;
		}
		else if(x == 0&&y==0){
			dizi[i]=0;
		}
	}
	for(i=0;i<strlen(c);i++){
		if(dizi[i]==1){
			sayi+= pow(2,strlen(c)-1-i);
		}
	}
	printf("%d",sayi);
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int fact(int x){
	int i,n=1;
	for(i=1;i<=x;i++){
		n=n*i;
	}
	return n;
}

int dizi[15];

int main() {
	int i,ctn=0,x,sayi=0,y=0;
	char c[15];
	scanf("%s",&c);
	for(i=0;i<strlen(c);i++){
		x = c[i]-48;
		if(i>0){
			y = c[i-1]-48;
		}
		if(x > 0){
			dizi[i]=1;
		}
		else if(x == 0&&y>1){
			dizi[i]=1;
		}
		else if(x == 0&&y==0){
			dizi[i]=0;
		}
	}
	for(i=0;i<strlen(c);i++){
		if(dizi[i]==1){
			sayi+= pow(2,strlen(c)-1-i);
		}
	}
	printf("%d",sayi);
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int fact(int x){
	int i,n=1;
	for(i=1;i<=x;i++){
		n=n*i;
	}
	return n;
}

int dizi[15];

int main() {
	int i,ctn=0,x,sayi=0,y=0,j;
	char c[15];
	scanf("%s",&c);
	for(i=0;i<strlen(c);i++){
		x = c[i]-48;
		if(i>0){
			y = c[i-1]-48;
		}
		if(i==0&&x>1){
			ctn = 1;
			break;
		}
		else if(x > 0){
			dizi[i]=1;
		}
		else if(x == 0&&y>1){
			ctn = strlen(c)-i;
			dizi[i]=1;
			for(j=i;j<strlen(c);j++){
				dizi[j]=1;
			}
			break;
		}
		else if(x == 0&&y==1){
			dizi[i]=0;
		}
	}
	if(ctn==1){
		for(i=0;i<strlen(c);i++){
			dizi[i]=1;
		}
	}
	for(i=0;i<strlen(c);i++){
		if(dizi[strlen(c)-i-1]==1){
			sayi += pow(2,i);
		}
	}
	printf("%d",sayi);
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int fact(int x){
	int i,n=1;
	for(i=1;i<=x;i++){
		n=n*i;
	}
	return n;
}

int dizi[15];

int main() {
	int i,ctn=0,x,sayi=0,y=0;
	char c[15];
	scanf("%s",&c);
	for(i=0;i<strlen(c);i++){
		x = c[i]-48;
		if(i>0){
			y = c[i-1]-48;
		}
		if(i==0&&x>1){
			ctn = 1;
		}
		if(x > 0){
			dizi[i]=1;
		}
		else if(x == 0&&y>0){
			dizi[i]=1;
		}
		else if(x == 0&&y==0){
			dizi[i]=0;
		}
	}
	if(ctn==1){
		for(i=0;i<strlen(c);i++){
			dizi[i]=1;
		}
	}
	for(i=0;i<strlen(c);i++){
		if(dizi[i]==1){
			sayi+= pow(2,strlen(c)-1-i);
		}
	}
	printf("%d",sayi);
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int fact(int x){
	int i,n=1;
	for(i=1;i<=x;i++){
		n=n*i;
	}
	return n;
}

int dizi[15];

int main() {
	int i,ctn=0,x,sayi=0;
	char c[15];
	scanf("%s",&c);
	for(i=0;i<strlen(c);i++){
		x = c[i]-48;
		if(x > 0){
			dizi[i]=1;
		}
		else if(x == 0){
			dizi[i]=0;
		}
	}
	for(i=0;i<strlen(c);i++){
		if(dizi[i]==1){
			sayi+= pow(2,strlen(c)-1-i);
		}
	}
	printf("%d",sayi);
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int fact(int x){
	int i,n=1;
	for(i=1;i<=x;i++){
		n=n*i;
	}
	return n;
}

int dizi[15];

int main() {
	int i,ctn=0,x,sayi=0,y=0;
	char c[15];
	scanf("%s",&c);
	for(i=0;i<strlen(c);i++){
		x = c[i]-48;
		if(i>0){
			y = c[i-1]-48;
		}
		if(i==0&&x>1){
			ctn = 1;
		}
		else if(x > 0){
			dizi[i]=1;
		}
		else if(x == 0&&y>1){
			dizi[i]=1;
		}
		else if(x == 0&&y==0){
			dizi[i]=0;
		}
	}
	if(ctn==1){
		for(i=0;i<strlen(c);i++){
			dizi[i]=1;
		}
	}
	for(i=0;i<strlen(c);i++){
		if(dizi[i]==1){
			sayi+= pow(2,strlen(c)-1-i);
		}
	}
	printf("%d",sayi);
}

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

char s[32];

int decToBinary(int n)
{
  int binaryNum[32];
   int i=0;
   while (n>0)
   {
     binaryNum[i]=n%2;
     n=n/2;
     i++;
   }

   for (int j=i-1;j>0;j--)
   {
     sprintf (s+strlen(s),"%d",binaryNum[j]);
   }
   int x = atoi (s);
   return x;
}

int main ()
{
 int n;
 int counter=0;
 scanf ("%d",&n);
 for (int i=1;decToBinary(i)<=n;i++)
 {
   counter++;
 }
 printf ("%d",counter);

}