import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        for(long i=0;;){
            if((1l<<i)<=n)i++;
            else {
                System.out.println((1l<<i)-1);
                break;
            }
        }


    }
} import java.lang.reflect.Array; Array java.lang.reflect import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        for(long i=0;;){
            if((1l<<i)<=n)i++;
            else {
                System.out.println((1l<<i)-1);
                break;
            }
        }


    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        for(long i=0;;){
            if((1l<<i)<=n)i++;
            else {
                System.out.println((1l<<i)-1);
                break;
            }
        }


    } main {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        for(long i=0;;){
            if((1l<<i)<=n)i++;
            else {
                System.out.println((1l<<i)-1);
                break;
            }
        }


    } Scanner in = new Scanner(System.in); in new Scanner(System.in) long n = in.nextLong(); n in.nextLong() in.nextLong in for(long i=0;;){
            if((1l<<i)<=n)i++;
            else {
                System.out.println((1l<<i)-1);
                break;
            }
        } long i=0; long i=0; i 0 {
            if((1l<<i)<=n)i++;
            else {
                System.out.println((1l<<i)-1);
                break;
            }
        } {
            if((1l<<i)<=n)i++;
            else {
                System.out.println((1l<<i)-1);
                break;
            }
        } if((1l<<i)<=n)i++;
            else {
                System.out.println((1l<<i)-1);
                break;
            } (1l<<i)<=n (1l<<i) 1l i n i++ i {
                System.out.println((1l<<i)-1);
                break;
            } System.out.println((1l<<i)-1) System.out.println System.out System System.out (1l<<i)-1 (1l<<i) 1l i 1 break; String[] args args public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        for(long i=0;;){
            if((1l<<i)<=n)i++;
            else {
                System.out.println((1l<<i)-1);
                break;
            }
        }


    }
} public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        for(long i=0;;){
            if((1l<<i)<=n)i++;
            else {
                System.out.println((1l<<i)-1);
                break;
            }
        }


    }
} Main
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        for(long i=0;;){
            if((1l<<i)<=n)i++;
            else {
                System.out.println((1l<<i)-1);
                break;
            }
        }


    }
}
