
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		long h = sc.nextLong();
		
		System.out.println((long)Math.pow(2,(int)(Math.log10(h)/Math.log10(2)) + 1) - 1);
	}

} import java.util.Scanner; Scanner 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();
		
		System.out.println((long)Math.pow(2,(int)(Math.log10(h)/Math.log10(2)) + 1) - 1);
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		long h = sc.nextLong();
		
		System.out.println((long)Math.pow(2,(int)(Math.log10(h)/Math.log10(2)) + 1) - 1);
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		long h = sc.nextLong();
		
		System.out.println((long)Math.pow(2,(int)(Math.log10(h)/Math.log10(2)) + 1) - 1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc System.out.println((long)Math.pow(2,(int)(Math.log10(h)/Math.log10(2)) + 1) - 1) System.out.println System.out System System.out (long)Math.pow(2,(int)(Math.log10(h)/Math.log10(2)) + 1) - 1 (long)Math.pow(2,(int)(Math.log10(h)/Math.log10(2)) + 1) Math.pow Math 2 (int)(Math.log10(h)/Math.log10(2)) + 1 (int)(Math.log10(h)/Math.log10(2)) Math.log10(h) Math.log10 Math h Math.log10(2) Math.log10 Math 2 1 1 String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		long h = sc.nextLong();
		
		System.out.println((long)Math.pow(2,(int)(Math.log10(h)/Math.log10(2)) + 1) - 1);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		long h = sc.nextLong();
		
		System.out.println((long)Math.pow(2,(int)(Math.log10(h)/Math.log10(2)) + 1) - 1);
	}

} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		long h = sc.nextLong();
		
		System.out.println((long)Math.pow(2,(int)(Math.log10(h)/Math.log10(2)) + 1) - 1);
	}

}
