import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        long a=sc.nextLong();
  		long ans=1;
        long c=1;
		while(a>1){
        	a=a/2;
            ans+=Math.pow(2,c);
            c++;
        }

    	System.out.println(ans);
    }
} import java.util.*; util.* java class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        long a=sc.nextLong();
  		long ans=1;
        long c=1;
		while(a>1){
        	a=a/2;
            ans+=Math.pow(2,c);
            c++;
        }

    	System.out.println(ans);
    }
} Main public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        long a=sc.nextLong();
  		long ans=1;
        long c=1;
		while(a>1){
        	a=a/2;
            ans+=Math.pow(2,c);
            c++;
        }

    	System.out.println(ans);
    } main {
	Scanner sc=new Scanner(System.in);
        long a=sc.nextLong();
  		long ans=1;
        long c=1;
		while(a>1){
        	a=a/2;
            ans+=Math.pow(2,c);
            c++;
        }

    	System.out.println(ans);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) long a=sc.nextLong(); a sc.nextLong() sc.nextLong sc long ans=1; ans 1 long c=1; c 1 while(a>1){
        	a=a/2;
            ans+=Math.pow(2,c);
            c++;
        } a>1 a 1 {
        	a=a/2;
            ans+=Math.pow(2,c);
            c++;
        } a=a/2 a a/2 a 2 ans+=Math.pow(2,c) ans Math.pow(2,c) Math.pow Math 2 c c++ c System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        long a=sc.nextLong();
  		long ans=1;
        long c=1;
		while(a>1){
        	a=a/2;
            ans+=Math.pow(2,c);
            c++;
        }

    	System.out.println(ans);
    }
}