import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc=new Scanner(System.in);
        double n=(double)sc.nextLong();
        long sum=0;
        long t=1;
        while(n!=1){
            n=Math.floor(n/2);
            sum+=t;
            t*=2;
        }
        System.out.println(sum+t);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc=new Scanner(System.in);
        double n=(double)sc.nextLong();
        long sum=0;
        long t=1;
        while(n!=1){
            n=Math.floor(n/2);
            sum+=t;
            t*=2;
        }
        System.out.println(sum+t);
    }
} Main public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc=new Scanner(System.in);
        double n=(double)sc.nextLong();
        long sum=0;
        long t=1;
        while(n!=1){
            n=Math.floor(n/2);
            sum+=t;
            t*=2;
        }
        System.out.println(sum+t);
    } main {
        // Your code here!
        Scanner sc=new Scanner(System.in);
        double n=(double)sc.nextLong();
        long sum=0;
        long t=1;
        while(n!=1){
            n=Math.floor(n/2);
            sum+=t;
            t*=2;
        }
        System.out.println(sum+t);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) double n=(double)sc.nextLong(); n (double)sc.nextLong() sc.nextLong sc long sum=0; sum 0 long t=1; t 1 while(n!=1){
            n=Math.floor(n/2);
            sum+=t;
            t*=2;
        } n!=1 n 1 {
            n=Math.floor(n/2);
            sum+=t;
            t*=2;
        } n=Math.floor(n/2) n Math.floor(n/2) Math.floor Math n/2 n 2 sum+=t sum t t*=2 t 2 System.out.println(sum+t) System.out.println System.out System System.out sum+t sum t String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc=new Scanner(System.in);
        double n=(double)sc.nextLong();
        long sum=0;
        long t=1;
        while(n!=1){
            n=Math.floor(n/2);
            sum+=t;
            t*=2;
        }
        System.out.println(sum+t);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc=new Scanner(System.in);
        double n=(double)sc.nextLong();
        long sum=0;
        long t=1;
        while(n!=1){
            n=Math.floor(n/2);
            sum+=t;
            t*=2;
        }
        System.out.println(sum+t);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc=new Scanner(System.in);
        double n=(double)sc.nextLong();
        long sum=0;
        long t=1;
        while(n!=1){
            n=Math.floor(n/2);
            sum+=t;
            t*=2;
        }
        System.out.println(sum+t);
    }
}
