import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner( System.in );

        long health = Long.parseLong(scan.next());
        health = Recursive(health);
        System.out.println(health);
    }

    public static long Recursive(long health){
        if(health == 1){
            return health;
        }else{
            long returnNum = Recursive(health/2);
            return 2*returnNum + 1;
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner( System.in );

        long health = Long.parseLong(scan.next());
        health = Recursive(health);
        System.out.println(health);
    }

    public static long Recursive(long health){
        if(health == 1){
            return health;
        }else{
            long returnNum = Recursive(health/2);
            return 2*returnNum + 1;
        }
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner( System.in );

        long health = Long.parseLong(scan.next());
        health = Recursive(health);
        System.out.println(health);
    } main {
        Scanner scan = new Scanner( System.in );

        long health = Long.parseLong(scan.next());
        health = Recursive(health);
        System.out.println(health);
    } Scanner scan = new Scanner( System.in ); scan new Scanner( System.in ) long health = Long.parseLong(scan.next()); health Long.parseLong(scan.next()) Long.parseLong Long scan.next() scan.next scan health = Recursive(health) health Recursive(health) Recursive health System.out.println(health) System.out.println System.out System System.out health String[] args args public static long Recursive(long health){
        if(health == 1){
            return health;
        }else{
            long returnNum = Recursive(health/2);
            return 2*returnNum + 1;
        }
    } Recursive {
        if(health == 1){
            return health;
        }else{
            long returnNum = Recursive(health/2);
            return 2*returnNum + 1;
        }
    } if(health == 1){
            return health;
        }else{
            long returnNum = Recursive(health/2);
            return 2*returnNum + 1;
        } health == 1 health 1 {
            return health;
        } return health; health {
            long returnNum = Recursive(health/2);
            return 2*returnNum + 1;
        } long returnNum = Recursive(health/2); returnNum Recursive(health/2) Recursive health/2 health 2 return 2*returnNum + 1; 2*returnNum + 1 2*returnNum 2 returnNum 1 long health health public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner( System.in );

        long health = Long.parseLong(scan.next());
        health = Recursive(health);
        System.out.println(health);
    }

    public static long Recursive(long health){
        if(health == 1){
            return health;
        }else{
            long returnNum = Recursive(health/2);
            return 2*returnNum + 1;
        }
    }
} public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner( System.in );

        long health = Long.parseLong(scan.next());
        health = Recursive(health);
        System.out.println(health);
    }

    public static long Recursive(long health){
        if(health == 1){
            return health;
        }else{
            long returnNum = Recursive(health/2);
            return 2*returnNum + 1;
        }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner( System.in );

        long health = Long.parseLong(scan.next());
        health = Recursive(health);
        System.out.println(health);
    }

    public static long Recursive(long health){
        if(health == 1){
            return health;
        }else{
            long returnNum = Recursive(health/2);
            return 2*returnNum + 1;
        }
    }
}