/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
	    long n = sc.nextLong();
	    int level = 0;
	    while(n > 0){
	    	++level;
	    	n/=2;
	    }
	    long ans = (1L<<level)-1;
		 System.out.print(ans);
		
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
	    long n = sc.nextLong();
	    int level = 0;
	    while(n > 0){
	    	++level;
	    	n/=2;
	    }
	    long ans = (1L<<level)-1;
		 System.out.print(ans);
		
	}
} Main public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
	    long n = sc.nextLong();
	    int level = 0;
	    while(n > 0){
	    	++level;
	    	n/=2;
	    }
	    long ans = (1L<<level)-1;
		 System.out.print(ans);
		
	} main {
		// your code goes here
		Scanner sc = new Scanner(System.in);
	    long n = sc.nextLong();
	    int level = 0;
	    while(n > 0){
	    	++level;
	    	n/=2;
	    }
	    long ans = (1L<<level)-1;
		 System.out.print(ans);
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = sc.nextLong(); n sc.nextLong() sc.nextLong sc int level = 0; level 0 while(n > 0){
	    	++level;
	    	n/=2;
	    } n > 0 n 0 {
	    	++level;
	    	n/=2;
	    } ++level level n/=2 n 2 long ans = (1L<<level)-1; ans (1L<<level)-1 (1L<<level) 1L level 1 System.out.print(ans) System.out.print System.out System System.out ans String[] args args public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
	    long n = sc.nextLong();
	    int level = 0;
	    while(n > 0){
	    	++level;
	    	n/=2;
	    }
	    long ans = (1L<<level)-1;
		 System.out.print(ans);
		
	}
} public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
	    long n = sc.nextLong();
	    int level = 0;
	    while(n > 0){
	    	++level;
	    	n/=2;
	    }
	    long ans = (1L<<level)-1;
		 System.out.print(ans);
		
	}
} Main
/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
	    long n = sc.nextLong();
	    int level = 0;
	    while(n > 0){
	    	++level;
	    	n/=2;
	    }
	    long ans = (1L<<level)-1;
		 System.out.print(ans);
		
	}
}