import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        if(H == 0){
            System.out.println(H);
            System.out.println(0);
            return;
        }
        long count = Main.countMaxMonster(H);
        System.out.println(count);
    }

    public static long countMaxMonster(long H){
        if(H == 1) return 1;
        long count = Main.countMaxMonster(H / 2 )* 2 + 1 ;
        return count;
    }

} import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        if(H == 0){
            System.out.println(H);
            System.out.println(0);
            return;
        }
        long count = Main.countMaxMonster(H);
        System.out.println(count);
    }

    public static long countMaxMonster(long H){
        if(H == 1) return 1;
        long count = Main.countMaxMonster(H / 2 )* 2 + 1 ;
        return count;
    }

} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        if(H == 0){
            System.out.println(H);
            System.out.println(0);
            return;
        }
        long count = Main.countMaxMonster(H);
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        if(H == 0){
            System.out.println(H);
            System.out.println(0);
            return;
        }
        long count = Main.countMaxMonster(H);
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc if(H == 0){
            System.out.println(H);
            System.out.println(0);
            return;
        } H == 0 H 0 {
            System.out.println(H);
            System.out.println(0);
            return;
        } System.out.println(H) System.out.println System.out System System.out H System.out.println(0) System.out.println System.out System System.out 0 return; long count = Main.countMaxMonster(H); count Main.countMaxMonster(H) Main.countMaxMonster Main H System.out.println(count) System.out.println System.out System System.out count String[] args args public static long countMaxMonster(long H){
        if(H == 1) return 1;
        long count = Main.countMaxMonster(H / 2 )* 2 + 1 ;
        return count;
    } countMaxMonster {
        if(H == 1) return 1;
        long count = Main.countMaxMonster(H / 2 )* 2 + 1 ;
        return count;
    } if(H == 1) return 1; H == 1 H 1 return 1; 1 long count = Main.countMaxMonster(H / 2 )* 2 + 1 ; count Main.countMaxMonster(H / 2 )* 2 + 1 Main.countMaxMonster(H / 2 )* 2 Main.countMaxMonster(H / 2 ) Main.countMaxMonster Main H / 2 H 2 2 1 return count; count long H H public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        if(H == 0){
            System.out.println(H);
            System.out.println(0);
            return;
        }
        long count = Main.countMaxMonster(H);
        System.out.println(count);
    }

    public static long countMaxMonster(long H){
        if(H == 1) return 1;
        long count = Main.countMaxMonster(H / 2 )* 2 + 1 ;
        return count;
    }

} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        if(H == 0){
            System.out.println(H);
            System.out.println(0);
            return;
        }
        long count = Main.countMaxMonster(H);
        System.out.println(count);
    }

    public static long countMaxMonster(long H){
        if(H == 1) return 1;
        long count = Main.countMaxMonster(H / 2 )* 2 + 1 ;
        return count;
    }

} Main
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        if(H == 0){
            System.out.println(H);
            System.out.println(0);
            return;
        }
        long count = Main.countMaxMonster(H);
        System.out.println(count);
    }

    public static long countMaxMonster(long H){
        if(H == 1) return 1;
        long count = Main.countMaxMonster(H / 2 )* 2 + 1 ;
        return count;
    }

}