/* 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
{
	static long solve(long n){
		long ans = 1l;
		while(n>0){
			n >>= 1l;
			ans <<= 1l;
		}
		return ans-1l;
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		System.out.println(solve(n));
		// your code goes here
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main
{
	static long solve(long n){
		long ans = 1l;
		while(n>0){
			n >>= 1l;
			ans <<= 1l;
		}
		return ans-1l;
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		System.out.println(solve(n));
		// your code goes here
	}
} Main static long solve(long n){
		long ans = 1l;
		while(n>0){
			n >>= 1l;
			ans <<= 1l;
		}
		return ans-1l;
	} solve {
		long ans = 1l;
		while(n>0){
			n >>= 1l;
			ans <<= 1l;
		}
		return ans-1l;
	} long ans = 1l; ans 1l while(n>0){
			n >>= 1l;
			ans <<= 1l;
		} n>0 n 0 {
			n >>= 1l;
			ans <<= 1l;
		} n >>= 1l n 1l ans <<= 1l ans 1l return ans-1l; ans-1l ans 1l long n n public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		System.out.println(solve(n));
		// your code goes here
	} main {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		System.out.println(solve(n));
		// your code goes here
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long n = scan.nextLong(); n scan.nextLong() scan.nextLong scan System.out.println(solve(n)) System.out.println System.out System System.out solve(n) solve n String[] args args public class Main
{
	static long solve(long n){
		long ans = 1l;
		while(n>0){
			n >>= 1l;
			ans <<= 1l;
		}
		return ans-1l;
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		System.out.println(solve(n));
		// your code goes here
	}
} public class Main
{
	static long solve(long n){
		long ans = 1l;
		while(n>0){
			n >>= 1l;
			ans <<= 1l;
		}
		return ans-1l;
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		System.out.println(solve(n));
		// your code goes here
	}
} 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
{
	static long solve(long n){
		long ans = 1l;
		while(n>0){
			n >>= 1l;
			ans <<= 1l;
		}
		return ans-1l;
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		System.out.println(solve(n));
		// your code goes here
	}
}