import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long ans = func(h);
        System.out.println(ans);
    }

    private static long func(long h) {
        if (h == 1) return 1;
        
        return 2 * func(h/2) + 1;
    }
} import java.util.*; util.* java public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long ans = func(h);
        System.out.println(ans);
    }

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

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

    private static long func(long h) {
        if (h == 1) return 1;
        
        return 2 * func(h/2) + 1;
    }
} Main
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long ans = func(h);
        System.out.println(ans);
    }

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