import java.util.*;
public class Main {
        public static void main(String[] args){
            Scanner sc=new Scanner(System.in);
            ArrayList<Integer> arr=new ArrayList<Integer>();
            while(sc.hasNextInt()){
                int n=sc.nextInt();
                arr.add(getmax(n));
            }
            for(int i=0;i<arr.size();i++){
                System.out.println(arr.get(i));
            }

        }
    public static int getmax(int n){
        int i=1;
        if(n<=1){
            //System.out.println(n);
            return n;
        }
        while(i<=n){
            i*=2;
        }
        //System.out.println(i/2-1);
        return i/2-1;
    }
}