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

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

/* 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
	{
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		BigInteger b = new BigInteger(s);
		int shift = b.toString(2).length();
		BigInteger ans = new BigInteger("1");
		ans = ans.shiftLeft(shift);
		ans = ans.subtract(new BigInteger("1"));
		System.out.println(ans);
		// your code goes here
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java import java.math.BigInteger; BigInteger java.math public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		BigInteger b = new BigInteger(s);
		int shift = b.toString(2).length();
		BigInteger ans = new BigInteger("1");
		ans = ans.shiftLeft(shift);
		ans = ans.subtract(new BigInteger("1"));
		System.out.println(ans);
		// your code goes here
	}
} Main public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		BigInteger b = new BigInteger(s);
		int shift = b.toString(2).length();
		BigInteger ans = new BigInteger("1");
		ans = ans.shiftLeft(shift);
		ans = ans.subtract(new BigInteger("1"));
		System.out.println(ans);
		// your code goes here
	} main {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		BigInteger b = new BigInteger(s);
		int shift = b.toString(2).length();
		BigInteger ans = new BigInteger("1");
		ans = ans.shiftLeft(shift);
		ans = ans.subtract(new BigInteger("1"));
		System.out.println(ans);
		// your code goes here
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String s = scan.next(); s scan.next() scan.next scan BigInteger b = new BigInteger(s); b new BigInteger(s) int shift = b.toString(2).length(); shift b.toString(2).length() b.toString(2).length b.toString(2) b.toString b 2 BigInteger ans = new BigInteger("1"); ans new BigInteger("1") ans = ans.shiftLeft(shift) ans ans.shiftLeft(shift) ans.shiftLeft ans shift ans = ans.subtract(new BigInteger("1")) ans ans.subtract(new BigInteger("1")) ans.subtract ans new BigInteger("1") System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		BigInteger b = new BigInteger(s);
		int shift = b.toString(2).length();
		BigInteger ans = new BigInteger("1");
		ans = ans.shiftLeft(shift);
		ans = ans.subtract(new BigInteger("1"));
		System.out.println(ans);
		// your code goes here
	}
} public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		BigInteger b = new BigInteger(s);
		int shift = b.toString(2).length();
		BigInteger ans = new BigInteger("1");
		ans = ans.shiftLeft(shift);
		ans = ans.subtract(new BigInteger("1"));
		System.out.println(ans);
		// your code goes here
	}
} Main
/* package whatever; // don't place package name! */

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

/* 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
	{
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		BigInteger b = new BigInteger(s);
		int shift = b.toString(2).length();
		BigInteger ans = new BigInteger("1");
		ans = ans.shiftLeft(shift);
		ans = ans.subtract(new BigInteger("1"));
		System.out.println(ans);
		// your code goes here
	}
}