import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		long n=in.nextLong();
		long ans=1;
		while(ans<=n)
			ans<<=1;
		System.out.println(ans-1);
	}
}
	 import java.util.*; util.* java import java.io.*; io.* java public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		long n=in.nextLong();
		long ans=1;
		while(ans<=n)
			ans<<=1;
		System.out.println(ans-1);
	}
} Main public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		long n=in.nextLong();
		long ans=1;
		while(ans<=n)
			ans<<=1;
		System.out.println(ans-1);
	} main {
		Scanner in=new Scanner(System.in);
		long n=in.nextLong();
		long ans=1;
		while(ans<=n)
			ans<<=1;
		System.out.println(ans-1);
	} Scanner in=new Scanner(System.in); in new Scanner(System.in) long n=in.nextLong(); n in.nextLong() in.nextLong in long ans=1; ans 1 while(ans<=n)
			ans<<=1; ans<=n ans n ans<<=1 ans 1 System.out.println(ans-1) System.out.println System.out System System.out ans-1 ans 1 String [] Args Args public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		long n=in.nextLong();
		long ans=1;
		while(ans<=n)
			ans<<=1;
		System.out.println(ans-1);
	}
} public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		long n=in.nextLong();
		long ans=1;
		while(ans<=n)
			ans<<=1;
		System.out.println(ans-1);
	}
} Main
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		long n=in.nextLong();
		long ans=1;
		while(ans<=n)
			ans<<=1;
		System.out.println(ans-1);
	}
}
	