import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long ans = 1;
        long i = 1;
        while(h > 1){
            h = h / 2;
            i = i *2;
            ans = ans + i;

        }
        
        System.out.println(ans);
    }
} import java.util.*; util.* java import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Arrays; Arrays java.util public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long ans = 1;
        long i = 1;
        while(h > 1){
            h = h / 2;
            i = i *2;
            ans = ans + i;

        }
        
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long ans = 1;
        long i = 1;
        while(h > 1){
            h = h / 2;
            i = i *2;
            ans = ans + i;

        }
        
        System.out.println(ans);
    } main {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long ans = 1;
        long i = 1;
        while(h > 1){
            h = h / 2;
            i = i *2;
            ans = ans + i;

        }
        
        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 = 1; ans 1 long i = 1; i 1 while(h > 1){
            h = h / 2;
            i = i *2;
            ans = ans + i;

        } h > 1 h 1 {
            h = h / 2;
            i = i *2;
            ans = ans + i;

        } h = h / 2 h h / 2 h 2 i = i *2 i i *2 i 2 ans = ans + i ans ans + i ans i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long ans = 1;
        long i = 1;
        while(h > 1){
            h = h / 2;
            i = i *2;
            ans = ans + i;

        }
        
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long ans = 1;
        long i = 1;
        while(h > 1){
            h = h / 2;
            i = i *2;
            ans = ans + i;

        }
        
        System.out.println(ans);
    }
} Main
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long ans = 1;
        long i = 1;
        while(h > 1){
            h = h / 2;
            i = i *2;
            ans = ans + i;

        }
        
        System.out.println(ans);
    }
}