import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		long h = parseLong(sc.next());
		sc.close();
		long ans = (long)pow(2,(long)floor(log(h)/log(2))+1)-1;
		out.println(ans);
	}
} import java.util.*; util.* java import java.io.PrintWriter; PrintWriter java.io import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
	public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		long h = parseLong(sc.next());
		sc.close();
		long ans = (long)pow(2,(long)floor(log(h)/log(2))+1)-1;
		out.println(ans);
	}
} Main public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		long h = parseLong(sc.next());
		sc.close();
		long ans = (long)pow(2,(long)floor(log(h)/log(2))+1)-1;
		out.println(ans);
	} main {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		long h = parseLong(sc.next());
		sc.close();
		long ans = (long)pow(2,(long)floor(log(h)/log(2))+1)-1;
		out.println(ans);
	} int i i j j k k l; l Scanner sc = new Scanner(in); sc new Scanner(in) long h = parseLong(sc.next()); h parseLong(sc.next()) parseLong sc.next() sc.next sc sc.close() sc.close sc long ans = (long)pow(2,(long)floor(log(h)/log(2))+1)-1; ans (long)pow(2,(long)floor(log(h)/log(2))+1)-1 (long)pow(2,(long)floor(log(h)/log(2))+1) pow 2 (long)floor(log(h)/log(2))+1 (long)floor(log(h)/log(2)) floor log(h)/log(2) log(h) log h log(2) log 2 1 1 out.println(ans) out.println out ans String[] args args public class Main {
	public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		long h = parseLong(sc.next());
		sc.close();
		long ans = (long)pow(2,(long)floor(log(h)/log(2))+1)-1;
		out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		long h = parseLong(sc.next());
		sc.close();
		long ans = (long)pow(2,(long)floor(log(h)/log(2))+1)-1;
		out.println(ans);
	}
} Main
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j,k,l;
		Scanner sc = new Scanner(in);
		long h = parseLong(sc.next());
		sc.close();
		long ans = (long)pow(2,(long)floor(log(h)/log(2))+1)-1;
		out.println(ans);
	}
}
