import java.util.*;

public class Main {
	private static long solve(long H) 
	{if(H==1) return 1;
	else return(2*solve(H/2)+1);
	}


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


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


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


	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		System.out.println(solve(sc.nextLong()));
	}
} Main
import java.util.*;

public class Main {
	private static long solve(long H) 
	{if(H==1) return 1;
	else return(2*solve(H/2)+1);
	}


	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		System.out.println(solve(sc.nextLong()));
	}
}