
import java.util.Scanner;

public class Main {
    static int binarySearchRightMost(int arr[],int key){
        int l=0,r=arr.length-1;
        while (l<r){
            int mid=Math.floorDiv(l+r,2);
            if(arr[mid]>key){
                r=mid;
            }
            else{
                l=mid+1;
            }
        }
        return r-1;

    }

    public static void main(String[] args) {
//        int arr[]={1,2,3,4,4,4,6,7};
//        System.out.println(binarySearchRightMost(arr,4));
        Scanner scanner=new Scanner(System.in);
        long n=scanner.nextLong();
        long ss=n;
        long total=0;
        if(ss>1) {
            for (int j = 0; j < 100; j++) {
                n/=2;
                //n = (long) Math.floorDiv((long) (long) n, (long) 2);
                total = (long) ((long) total + (long) Math.pow(2, j));
                if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                }
            }
        }
        if(ss==1){
            System.out.println(1);
        }else{
        System.out.println(total);}
//        int k=scanner.nextInt();
//        long arr[]=new long[n];
//        for(int j=0;j<n;j++){
//            arr[j]=scanner.nextLong();
//        }
//        Arrays.sort(arr);
//        int c=0;
//        if(k>0) {
//            for (int j = arr.length - 1; j >= 0; j--) {
//                arr[j] = 0;
//                c++;
//                if (c == k) {
//                    break;
//                }
//            }
//        }
//        long ans=0;
//        for(int j=0;j<arr.length;j++){
//            ans=(long)((long)ans+(long)arr[j]);
//        }
//        System.out.println(ans);
//        int arr[]=new int[b];
//        for(int j=0;j<b;j++){
//            a-=scanner.nextInt();
//            if(a<=0){
//                System.out.println("Yes");
//                break;
//            }
//        }
//        if(a>0){
//            System.out.println("No");
//        }
//        System.out.println(a%b==0?Math.floorDiv(a,b):Math.floorDiv(a,b)+1);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    static int binarySearchRightMost(int arr[],int key){
        int l=0,r=arr.length-1;
        while (l<r){
            int mid=Math.floorDiv(l+r,2);
            if(arr[mid]>key){
                r=mid;
            }
            else{
                l=mid+1;
            }
        }
        return r-1;

    }

    public static void main(String[] args) {
//        int arr[]={1,2,3,4,4,4,6,7};
//        System.out.println(binarySearchRightMost(arr,4));
        Scanner scanner=new Scanner(System.in);
        long n=scanner.nextLong();
        long ss=n;
        long total=0;
        if(ss>1) {
            for (int j = 0; j < 100; j++) {
                n/=2;
                //n = (long) Math.floorDiv((long) (long) n, (long) 2);
                total = (long) ((long) total + (long) Math.pow(2, j));
                if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                }
            }
        }
        if(ss==1){
            System.out.println(1);
        }else{
        System.out.println(total);}
//        int k=scanner.nextInt();
//        long arr[]=new long[n];
//        for(int j=0;j<n;j++){
//            arr[j]=scanner.nextLong();
//        }
//        Arrays.sort(arr);
//        int c=0;
//        if(k>0) {
//            for (int j = arr.length - 1; j >= 0; j--) {
//                arr[j] = 0;
//                c++;
//                if (c == k) {
//                    break;
//                }
//            }
//        }
//        long ans=0;
//        for(int j=0;j<arr.length;j++){
//            ans=(long)((long)ans+(long)arr[j]);
//        }
//        System.out.println(ans);
//        int arr[]=new int[b];
//        for(int j=0;j<b;j++){
//            a-=scanner.nextInt();
//            if(a<=0){
//                System.out.println("Yes");
//                break;
//            }
//        }
//        if(a>0){
//            System.out.println("No");
//        }
//        System.out.println(a%b==0?Math.floorDiv(a,b):Math.floorDiv(a,b)+1);
    }
} Main static int binarySearchRightMost(int arr[],int key){
        int l=0,r=arr.length-1;
        while (l<r){
            int mid=Math.floorDiv(l+r,2);
            if(arr[mid]>key){
                r=mid;
            }
            else{
                l=mid+1;
            }
        }
        return r-1;

    } binarySearchRightMost {
        int l=0,r=arr.length-1;
        while (l<r){
            int mid=Math.floorDiv(l+r,2);
            if(arr[mid]>key){
                r=mid;
            }
            else{
                l=mid+1;
            }
        }
        return r-1;

    } int l=0 l 0 r=arr.length-1; r arr.length-1 arr.length arr arr.length 1 while (l<r){
            int mid=Math.floorDiv(l+r,2);
            if(arr[mid]>key){
                r=mid;
            }
            else{
                l=mid+1;
            }
        } l<r l r {
            int mid=Math.floorDiv(l+r,2);
            if(arr[mid]>key){
                r=mid;
            }
            else{
                l=mid+1;
            }
        } int mid=Math.floorDiv(l+r,2); mid Math.floorDiv(l+r,2) Math.floorDiv Math l+r l r 2 if(arr[mid]>key){
                r=mid;
            }
            else{
                l=mid+1;
            } arr[mid]>key arr[mid] arr mid key {
                r=mid;
            } r=mid r mid {
                l=mid+1;
            } l=mid+1 l mid+1 mid 1 return r-1; r-1 r 1 int arr[] arr int key key public static void main(String[] args) {
//        int arr[]={1,2,3,4,4,4,6,7};
//        System.out.println(binarySearchRightMost(arr,4));
        Scanner scanner=new Scanner(System.in);
        long n=scanner.nextLong();
        long ss=n;
        long total=0;
        if(ss>1) {
            for (int j = 0; j < 100; j++) {
                n/=2;
                //n = (long) Math.floorDiv((long) (long) n, (long) 2);
                total = (long) ((long) total + (long) Math.pow(2, j));
                if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                }
            }
        }
        if(ss==1){
            System.out.println(1);
        }else{
        System.out.println(total);}
//        int k=scanner.nextInt();
//        long arr[]=new long[n];
//        for(int j=0;j<n;j++){
//            arr[j]=scanner.nextLong();
//        }
//        Arrays.sort(arr);
//        int c=0;
//        if(k>0) {
//            for (int j = arr.length - 1; j >= 0; j--) {
//                arr[j] = 0;
//                c++;
//                if (c == k) {
//                    break;
//                }
//            }
//        }
//        long ans=0;
//        for(int j=0;j<arr.length;j++){
//            ans=(long)((long)ans+(long)arr[j]);
//        }
//        System.out.println(ans);
//        int arr[]=new int[b];
//        for(int j=0;j<b;j++){
//            a-=scanner.nextInt();
//            if(a<=0){
//                System.out.println("Yes");
//                break;
//            }
//        }
//        if(a>0){
//            System.out.println("No");
//        }
//        System.out.println(a%b==0?Math.floorDiv(a,b):Math.floorDiv(a,b)+1);
    } main {
//        int arr[]={1,2,3,4,4,4,6,7};
//        System.out.println(binarySearchRightMost(arr,4));
        Scanner scanner=new Scanner(System.in);
        long n=scanner.nextLong();
        long ss=n;
        long total=0;
        if(ss>1) {
            for (int j = 0; j < 100; j++) {
                n/=2;
                //n = (long) Math.floorDiv((long) (long) n, (long) 2);
                total = (long) ((long) total + (long) Math.pow(2, j));
                if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                }
            }
        }
        if(ss==1){
            System.out.println(1);
        }else{
        System.out.println(total);}
//        int k=scanner.nextInt();
//        long arr[]=new long[n];
//        for(int j=0;j<n;j++){
//            arr[j]=scanner.nextLong();
//        }
//        Arrays.sort(arr);
//        int c=0;
//        if(k>0) {
//            for (int j = arr.length - 1; j >= 0; j--) {
//                arr[j] = 0;
//                c++;
//                if (c == k) {
//                    break;
//                }
//            }
//        }
//        long ans=0;
//        for(int j=0;j<arr.length;j++){
//            ans=(long)((long)ans+(long)arr[j]);
//        }
//        System.out.println(ans);
//        int arr[]=new int[b];
//        for(int j=0;j<b;j++){
//            a-=scanner.nextInt();
//            if(a<=0){
//                System.out.println("Yes");
//                break;
//            }
//        }
//        if(a>0){
//            System.out.println("No");
//        }
//        System.out.println(a%b==0?Math.floorDiv(a,b):Math.floorDiv(a,b)+1);
    } Scanner scanner=new Scanner(System.in); scanner new Scanner(System.in) long n=scanner.nextLong(); n scanner.nextLong() scanner.nextLong scanner long ss=n; ss n long total=0; total 0 if(ss>1) {
            for (int j = 0; j < 100; j++) {
                n/=2;
                //n = (long) Math.floorDiv((long) (long) n, (long) 2);
                total = (long) ((long) total + (long) Math.pow(2, j));
                if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                }
            }
        } ss>1 ss 1 {
            for (int j = 0; j < 100; j++) {
                n/=2;
                //n = (long) Math.floorDiv((long) (long) n, (long) 2);
                total = (long) ((long) total + (long) Math.pow(2, j));
                if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                }
            }
        } for (int j = 0; j < 100; j++) {
                n/=2;
                //n = (long) Math.floorDiv((long) (long) n, (long) 2);
                total = (long) ((long) total + (long) Math.pow(2, j));
                if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                }
            } int j = 0; int j = 0; j 0 j < 100 j 100 j++ j++ j {
                n/=2;
                //n = (long) Math.floorDiv((long) (long) n, (long) 2);
                total = (long) ((long) total + (long) Math.pow(2, j));
                if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                }
            } {
                n/=2;
                //n = (long) Math.floorDiv((long) (long) n, (long) 2);
                total = (long) ((long) total + (long) Math.pow(2, j));
                if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                }
            } n/=2 n 2 total = (long) ((long) total + (long) Math.pow(2, j)) total (long) ((long) total + (long) Math.pow(2, j)) (long) total (long) Math.pow(2, j) Math.pow Math 2 j if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                } n == 1 n 1 {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                } total = (long) ((long) total + (long) Math.pow(2, j + 1)) total (long) ((long) total + (long) Math.pow(2, j + 1)) (long) total (long) Math.pow(2, j + 1) Math.pow Math 2 j + 1 j 1 break; if(ss==1){
            System.out.println(1);
        }else{
        System.out.println(total);} ss==1 ss 1 {
            System.out.println(1);
        } System.out.println(1) System.out.println System.out System System.out 1 {
        System.out.println(total);} System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
    static int binarySearchRightMost(int arr[],int key){
        int l=0,r=arr.length-1;
        while (l<r){
            int mid=Math.floorDiv(l+r,2);
            if(arr[mid]>key){
                r=mid;
            }
            else{
                l=mid+1;
            }
        }
        return r-1;

    }

    public static void main(String[] args) {
//        int arr[]={1,2,3,4,4,4,6,7};
//        System.out.println(binarySearchRightMost(arr,4));
        Scanner scanner=new Scanner(System.in);
        long n=scanner.nextLong();
        long ss=n;
        long total=0;
        if(ss>1) {
            for (int j = 0; j < 100; j++) {
                n/=2;
                //n = (long) Math.floorDiv((long) (long) n, (long) 2);
                total = (long) ((long) total + (long) Math.pow(2, j));
                if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                }
            }
        }
        if(ss==1){
            System.out.println(1);
        }else{
        System.out.println(total);}
//        int k=scanner.nextInt();
//        long arr[]=new long[n];
//        for(int j=0;j<n;j++){
//            arr[j]=scanner.nextLong();
//        }
//        Arrays.sort(arr);
//        int c=0;
//        if(k>0) {
//            for (int j = arr.length - 1; j >= 0; j--) {
//                arr[j] = 0;
//                c++;
//                if (c == k) {
//                    break;
//                }
//            }
//        }
//        long ans=0;
//        for(int j=0;j<arr.length;j++){
//            ans=(long)((long)ans+(long)arr[j]);
//        }
//        System.out.println(ans);
//        int arr[]=new int[b];
//        for(int j=0;j<b;j++){
//            a-=scanner.nextInt();
//            if(a<=0){
//                System.out.println("Yes");
//                break;
//            }
//        }
//        if(a>0){
//            System.out.println("No");
//        }
//        System.out.println(a%b==0?Math.floorDiv(a,b):Math.floorDiv(a,b)+1);
    }
} public class Main {
    static int binarySearchRightMost(int arr[],int key){
        int l=0,r=arr.length-1;
        while (l<r){
            int mid=Math.floorDiv(l+r,2);
            if(arr[mid]>key){
                r=mid;
            }
            else{
                l=mid+1;
            }
        }
        return r-1;

    }

    public static void main(String[] args) {
//        int arr[]={1,2,3,4,4,4,6,7};
//        System.out.println(binarySearchRightMost(arr,4));
        Scanner scanner=new Scanner(System.in);
        long n=scanner.nextLong();
        long ss=n;
        long total=0;
        if(ss>1) {
            for (int j = 0; j < 100; j++) {
                n/=2;
                //n = (long) Math.floorDiv((long) (long) n, (long) 2);
                total = (long) ((long) total + (long) Math.pow(2, j));
                if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                }
            }
        }
        if(ss==1){
            System.out.println(1);
        }else{
        System.out.println(total);}
//        int k=scanner.nextInt();
//        long arr[]=new long[n];
//        for(int j=0;j<n;j++){
//            arr[j]=scanner.nextLong();
//        }
//        Arrays.sort(arr);
//        int c=0;
//        if(k>0) {
//            for (int j = arr.length - 1; j >= 0; j--) {
//                arr[j] = 0;
//                c++;
//                if (c == k) {
//                    break;
//                }
//            }
//        }
//        long ans=0;
//        for(int j=0;j<arr.length;j++){
//            ans=(long)((long)ans+(long)arr[j]);
//        }
//        System.out.println(ans);
//        int arr[]=new int[b];
//        for(int j=0;j<b;j++){
//            a-=scanner.nextInt();
//            if(a<=0){
//                System.out.println("Yes");
//                break;
//            }
//        }
//        if(a>0){
//            System.out.println("No");
//        }
//        System.out.println(a%b==0?Math.floorDiv(a,b):Math.floorDiv(a,b)+1);
    }
} Main

import java.util.Scanner;

public class Main {
    static int binarySearchRightMost(int arr[],int key){
        int l=0,r=arr.length-1;
        while (l<r){
            int mid=Math.floorDiv(l+r,2);
            if(arr[mid]>key){
                r=mid;
            }
            else{
                l=mid+1;
            }
        }
        return r-1;

    }

    public static void main(String[] args) {
//        int arr[]={1,2,3,4,4,4,6,7};
//        System.out.println(binarySearchRightMost(arr,4));
        Scanner scanner=new Scanner(System.in);
        long n=scanner.nextLong();
        long ss=n;
        long total=0;
        if(ss>1) {
            for (int j = 0; j < 100; j++) {
                n/=2;
                //n = (long) Math.floorDiv((long) (long) n, (long) 2);
                total = (long) ((long) total + (long) Math.pow(2, j));
                if (n == 1) {
                    total = (long) ((long) total + (long) Math.pow(2, j + 1));
                    break;
                }
            }
        }
        if(ss==1){
            System.out.println(1);
        }else{
        System.out.println(total);}
//        int k=scanner.nextInt();
//        long arr[]=new long[n];
//        for(int j=0;j<n;j++){
//            arr[j]=scanner.nextLong();
//        }
//        Arrays.sort(arr);
//        int c=0;
//        if(k>0) {
//            for (int j = arr.length - 1; j >= 0; j--) {
//                arr[j] = 0;
//                c++;
//                if (c == k) {
//                    break;
//                }
//            }
//        }
//        long ans=0;
//        for(int j=0;j<arr.length;j++){
//            ans=(long)((long)ans+(long)arr[j]);
//        }
//        System.out.println(ans);
//        int arr[]=new int[b];
//        for(int j=0;j<b;j++){
//            a-=scanner.nextInt();
//            if(a<=0){
//                System.out.println("Yes");
//                break;
//            }
//        }
//        if(a>0){
//            System.out.println("No");
//        }
//        System.out.println(a%b==0?Math.floorDiv(a,b):Math.floorDiv(a,b)+1);
    }
}
