import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		double h = scan.nextLong();
		h = Math.log(h) / Math.log(2);
		long n = (long)h;
		
		double x = Math.pow(2,n+1);
		long ans = (long)x;
		System.out.println(ans-1);
		
	}
}

 import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		double h = scan.nextLong();
		h = Math.log(h) / Math.log(2);
		long n = (long)h;
		
		double x = Math.pow(2,n+1);
		long ans = (long)x;
		System.out.println(ans-1);
		
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		double h = scan.nextLong();
		h = Math.log(h) / Math.log(2);
		long n = (long)h;
		
		double x = Math.pow(2,n+1);
		long ans = (long)x;
		System.out.println(ans-1);
		
	} main {
		Scanner scan = new Scanner(System.in);
		
		double h = scan.nextLong();
		h = Math.log(h) / Math.log(2);
		long n = (long)h;
		
		double x = Math.pow(2,n+1);
		long ans = (long)x;
		System.out.println(ans-1);
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) double h = scan.nextLong(); h scan.nextLong() scan.nextLong scan h = Math.log(h) / Math.log(2) h Math.log(h) / Math.log(2) Math.log(h) Math.log Math h Math.log(2) Math.log Math 2 long n = (long)h; n (long)h double x = Math.pow(2,n+1); x Math.pow(2,n+1) Math.pow Math 2 n+1 n 1 long ans = (long)x; ans (long)x System.out.println(ans-1) System.out.println System.out System System.out ans-1 ans 1 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		double h = scan.nextLong();
		h = Math.log(h) / Math.log(2);
		long n = (long)h;
		
		double x = Math.pow(2,n+1);
		long ans = (long)x;
		System.out.println(ans-1);
		
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		double h = scan.nextLong();
		h = Math.log(h) / Math.log(2);
		long n = (long)h;
		
		double x = Math.pow(2,n+1);
		long ans = (long)x;
		System.out.println(ans-1);
		
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		double h = scan.nextLong();
		h = Math.log(h) / Math.log(2);
		long n = (long)h;
		
		double x = Math.pow(2,n+1);
		long ans = (long)x;
		System.out.println(ans-1);
		
	}
}


