import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		double s =  (Math.log(h)/Math.log(2));
		//System.out.println((long)s);
		if(h==1) {
			System.out.println(h);
		}
		else {
			int n = (int)s;
			long h1 = 2*(power(2,n)-1);
			System.out.println(h1+1);
			
		}
		
	}
	static long power(int x, int y) 
    { 
        if (y == 0) 
            return 1; 
        else if (y % 2 == 0) 
            return power(x, y / 2) * power(x, y / 2); 
        else
            return x * power(x, y / 2) * power(x, y / 2); 
    } 

} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		double s =  (Math.log(h)/Math.log(2));
		//System.out.println((long)s);
		if(h==1) {
			System.out.println(h);
		}
		else {
			int n = (int)s;
			long h1 = 2*(power(2,n)-1);
			System.out.println(h1+1);
			
		}
		
	}
	static long power(int x, int y) 
    { 
        if (y == 0) 
            return 1; 
        else if (y % 2 == 0) 
            return power(x, y / 2) * power(x, y / 2); 
        else
            return x * power(x, y / 2) * power(x, y / 2); 
    } 

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		double s =  (Math.log(h)/Math.log(2));
		//System.out.println((long)s);
		if(h==1) {
			System.out.println(h);
		}
		else {
			int n = (int)s;
			long h1 = 2*(power(2,n)-1);
			System.out.println(h1+1);
			
		}
		
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		double s =  (Math.log(h)/Math.log(2));
		//System.out.println((long)s);
		if(h==1) {
			System.out.println(h);
		}
		else {
			int n = (int)s;
			long h1 = 2*(power(2,n)-1);
			System.out.println(h1+1);
			
		}
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc double s =  (Math.log(h)/Math.log(2)); s (Math.log(h)/Math.log(2)) Math.log(h) Math.log Math h Math.log(2) Math.log Math 2 if(h==1) {
			System.out.println(h);
		}
		else {
			int n = (int)s;
			long h1 = 2*(power(2,n)-1);
			System.out.println(h1+1);
			
		} h==1 h 1 {
			System.out.println(h);
		} System.out.println(h) System.out.println System.out System System.out h {
			int n = (int)s;
			long h1 = 2*(power(2,n)-1);
			System.out.println(h1+1);
			
		} int n = (int)s; n (int)s long h1 = 2*(power(2,n)-1); h1 2*(power(2,n)-1) 2 (power(2,n)-1) power(2,n) power 2 n 1 System.out.println(h1+1) System.out.println System.out System System.out h1+1 h1 1 String[] args args static long power(int x, int y) 
    { 
        if (y == 0) 
            return 1; 
        else if (y % 2 == 0) 
            return power(x, y / 2) * power(x, y / 2); 
        else
            return x * power(x, y / 2) * power(x, y / 2); 
    } power { 
        if (y == 0) 
            return 1; 
        else if (y % 2 == 0) 
            return power(x, y / 2) * power(x, y / 2); 
        else
            return x * power(x, y / 2) * power(x, y / 2); 
    } if (y == 0) 
            return 1; 
        else if (y % 2 == 0) 
            return power(x, y / 2) * power(x, y / 2); 
        else
            return x * power(x, y / 2) * power(x, y / 2); y == 0 y 0 return 1; 1 if (y % 2 == 0) 
            return power(x, y / 2) * power(x, y / 2); 
        else
            return x * power(x, y / 2) * power(x, y / 2); y % 2 == 0 y % 2 y 2 0 return power(x, y / 2) * power(x, y / 2); power(x, y / 2) * power(x, y / 2) power(x, y / 2) power x y / 2 y 2 power(x, y / 2) power x y / 2 y 2 return x * power(x, y / 2) * power(x, y / 2); x * power(x, y / 2) * power(x, y / 2) x * power(x, y / 2) * power(x, y / 2) x power(x, y / 2) power x y / 2 y 2 power(x, y / 2) power x y / 2 y 2 int x x int y y public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		double s =  (Math.log(h)/Math.log(2));
		//System.out.println((long)s);
		if(h==1) {
			System.out.println(h);
		}
		else {
			int n = (int)s;
			long h1 = 2*(power(2,n)-1);
			System.out.println(h1+1);
			
		}
		
	}
	static long power(int x, int y) 
    { 
        if (y == 0) 
            return 1; 
        else if (y % 2 == 0) 
            return power(x, y / 2) * power(x, y / 2); 
        else
            return x * power(x, y / 2) * power(x, y / 2); 
    } 

} public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		double s =  (Math.log(h)/Math.log(2));
		//System.out.println((long)s);
		if(h==1) {
			System.out.println(h);
		}
		else {
			int n = (int)s;
			long h1 = 2*(power(2,n)-1);
			System.out.println(h1+1);
			
		}
		
	}
	static long power(int x, int y) 
    { 
        if (y == 0) 
            return 1; 
        else if (y % 2 == 0) 
            return power(x, y / 2) * power(x, y / 2); 
        else
            return x * power(x, y / 2) * power(x, y / 2); 
    } 

} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		double s =  (Math.log(h)/Math.log(2));
		//System.out.println((long)s);
		if(h==1) {
			System.out.println(h);
		}
		else {
			int n = (int)s;
			long h1 = 2*(power(2,n)-1);
			System.out.println(h1+1);
			
		}
		
	}
	static long power(int x, int y) 
    { 
        if (y == 0) 
            return 1; 
        else if (y % 2 == 0) 
            return power(x, y / 2) * power(x, y / 2); 
        else
            return x * power(x, y / 2) * power(x, y / 2); 
    } 

}
