import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long hp = sc.nextLong();
		System.out.println(at(hp));
	}

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

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

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

	static long at(long hp) {
		if(hp==1) return 1;
		return 2*at((long)hp/2)+1;
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long hp = sc.nextLong();
		System.out.println(at(hp));
	}

	static long at(long hp) {
		if(hp==1) return 1;
		return 2*at((long)hp/2)+1;
	}
}