import java.util.*;

 class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int x = (int)(Math.log(n)/Math.log(2));
	    System.out.println((long)(Math.pow(2,x+1)-1));
	}
}
 import java.util.*; util.* java class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int x = (int)(Math.log(n)/Math.log(2));
	    System.out.println((long)(Math.pow(2,x+1)-1));
	}
} Main public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int x = (int)(Math.log(n)/Math.log(2));
	    System.out.println((long)(Math.pow(2,x+1)-1));
	} main {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int x = (int)(Math.log(n)/Math.log(2));
	    System.out.println((long)(Math.pow(2,x+1)-1));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = sc.nextLong(); n sc.nextLong() sc.nextLong sc int x = (int)(Math.log(n)/Math.log(2)); x (int)(Math.log(n)/Math.log(2)) Math.log(n) Math.log Math n Math.log(2) Math.log Math 2 System.out.println((long)(Math.pow(2,x+1)-1)) System.out.println System.out System System.out (long)(Math.pow(2,x+1)-1) Math.pow(2,x+1) Math.pow Math 2 x+1 x 1 1 String[] args args
import java.util.*;

 class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int x = (int)(Math.log(n)/Math.log(2));
	    System.out.println((long)(Math.pow(2,x+1)-1));
	}
}

