import java.util.*;

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

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