import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long count = 1;
		while(H > 0) {
			H = H / 2;
			count *= 2;
		}
		System.out.println(count - 1);
	}
} import java.util.*; util.* java public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long count = 1;
		while(H > 0) {
			H = H / 2;
			count *= 2;
		}
		System.out.println(count - 1);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long count = 1;
		while(H > 0) {
			H = H / 2;
			count *= 2;
		}
		System.out.println(count - 1);
	} main {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long count = 1;
		while(H > 0) {
			H = H / 2;
			count *= 2;
		}
		System.out.println(count - 1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc long count = 1; count 1 while(H > 0) {
			H = H / 2;
			count *= 2;
		} H > 0 H 0 {
			H = H / 2;
			count *= 2;
		} H = H / 2 H H / 2 H 2 count *= 2 count 2 System.out.println(count - 1) System.out.println System.out System System.out count - 1 count 1 String[] args args public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long count = 1;
		while(H > 0) {
			H = H / 2;
			count *= 2;
		}
		System.out.println(count - 1);
	}
} public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long count = 1;
		while(H > 0) {
			H = H / 2;
			count *= 2;
		}
		System.out.println(count - 1);
	}
} Main
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long count = 1;
		while(H > 0) {
			H = H / 2;
			count *= 2;
		}
		System.out.println(count - 1);
	}
}