import java.util.*;

public class Main {

    public static long attack( long h ){
        if( h == 1 ){
            return 1;
        }
        return 2 * attack( h / 2 ) + 1;
    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.nextLine());
        System.out.println( attack( h ) );

    }

} import java.util.*; util.* java public class Main {

    public static long attack( long h ){
        if( h == 1 ){
            return 1;
        }
        return 2 * attack( h / 2 ) + 1;
    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.nextLine());
        System.out.println( attack( h ) );

    }

} Main public static long attack( long h ){
        if( h == 1 ){
            return 1;
        }
        return 2 * attack( h / 2 ) + 1;
    } attack {
        if( h == 1 ){
            return 1;
        }
        return 2 * attack( h / 2 ) + 1;
    } if( h == 1 ){
            return 1;
        } h == 1 h 1 {
            return 1;
        } return 1; 1 return 2 * attack( h / 2 ) + 1; 2 * attack( h / 2 ) + 1 2 * attack( h / 2 ) 2 attack( h / 2 ) attack h / 2 h 2 1 long h h public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.nextLine());
        System.out.println( attack( h ) );

    } main {

        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.nextLine());
        System.out.println( attack( h ) );

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = Long.parseLong(sc.nextLine()); h Long.parseLong(sc.nextLine()) Long.parseLong Long sc.nextLine() sc.nextLine sc System.out.println( attack( h ) ) System.out.println System.out System System.out attack( h ) attack h String[] args args public class Main {

    public static long attack( long h ){
        if( h == 1 ){
            return 1;
        }
        return 2 * attack( h / 2 ) + 1;
    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.nextLine());
        System.out.println( attack( h ) );

    }

} public class Main {

    public static long attack( long h ){
        if( h == 1 ){
            return 1;
        }
        return 2 * attack( h / 2 ) + 1;
    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.nextLine());
        System.out.println( attack( h ) );

    }

} Main
import java.util.*;

public class Main {

    public static long attack( long h ){
        if( h == 1 ){
            return 1;
        }
        return 2 * attack( h / 2 ) + 1;
    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.nextLine());
        System.out.println( attack( h ) );

    }

}
