import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        long numHP = sc.nextLong();
        long attackCnt = 0;

        if(numHP == 1) {
            attackCnt = 1;
        }
        
        for (int i=0; i<numHP; i++) {
            if(numHP >= Math.pow(2, i)) {
                if(numHP < Math.pow(2, i+1)) {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                }
            } 
        }

        
        System.out.println(attackCnt);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        long numHP = sc.nextLong();
        long attackCnt = 0;

        if(numHP == 1) {
            attackCnt = 1;
        }
        
        for (int i=0; i<numHP; i++) {
            if(numHP >= Math.pow(2, i)) {
                if(numHP < Math.pow(2, i+1)) {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                }
            } 
        }

        
        System.out.println(attackCnt);
    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        long numHP = sc.nextLong();
        long attackCnt = 0;

        if(numHP == 1) {
            attackCnt = 1;
        }
        
        for (int i=0; i<numHP; i++) {
            if(numHP >= Math.pow(2, i)) {
                if(numHP < Math.pow(2, i+1)) {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                }
            } 
        }

        
        System.out.println(attackCnt);
    } main {

        Scanner sc = new Scanner(System.in);
        
        long numHP = sc.nextLong();
        long attackCnt = 0;

        if(numHP == 1) {
            attackCnt = 1;
        }
        
        for (int i=0; i<numHP; i++) {
            if(numHP >= Math.pow(2, i)) {
                if(numHP < Math.pow(2, i+1)) {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                }
            } 
        }

        
        System.out.println(attackCnt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long numHP = sc.nextLong(); numHP sc.nextLong() sc.nextLong sc long attackCnt = 0; attackCnt 0 if(numHP == 1) {
            attackCnt = 1;
        } numHP == 1 numHP 1 {
            attackCnt = 1;
        } attackCnt = 1 attackCnt 1 for (int i=0; i<numHP; i++) {
            if(numHP >= Math.pow(2, i)) {
                if(numHP < Math.pow(2, i+1)) {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                }
            } 
        } int i=0; int i=0; i 0 i<numHP i numHP i++ i++ i {
            if(numHP >= Math.pow(2, i)) {
                if(numHP < Math.pow(2, i+1)) {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                }
            } 
        } {
            if(numHP >= Math.pow(2, i)) {
                if(numHP < Math.pow(2, i+1)) {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                }
            } 
        } if(numHP >= Math.pow(2, i)) {
                if(numHP < Math.pow(2, i+1)) {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                }
            } numHP >= Math.pow(2, i) numHP Math.pow(2, i) Math.pow Math 2 i {
                if(numHP < Math.pow(2, i+1)) {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                }
            } if(numHP < Math.pow(2, i+1)) {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                } numHP < Math.pow(2, i+1) numHP Math.pow(2, i+1) Math.pow Math 2 i+1 i 1 {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                } attackCnt = (long)Math.pow(2, i + 1) - 1 attackCnt (long)Math.pow(2, i + 1) - 1 (long)Math.pow(2, i + 1) Math.pow Math 2 i + 1 i 1 1 break; System.out.println(attackCnt) System.out.println System.out System System.out attackCnt String[] args args public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        long numHP = sc.nextLong();
        long attackCnt = 0;

        if(numHP == 1) {
            attackCnt = 1;
        }
        
        for (int i=0; i<numHP; i++) {
            if(numHP >= Math.pow(2, i)) {
                if(numHP < Math.pow(2, i+1)) {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                }
            } 
        }

        
        System.out.println(attackCnt);
    }
} public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        long numHP = sc.nextLong();
        long attackCnt = 0;

        if(numHP == 1) {
            attackCnt = 1;
        }
        
        for (int i=0; i<numHP; i++) {
            if(numHP >= Math.pow(2, i)) {
                if(numHP < Math.pow(2, i+1)) {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                }
            } 
        }

        
        System.out.println(attackCnt);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        long numHP = sc.nextLong();
        long attackCnt = 0;

        if(numHP == 1) {
            attackCnt = 1;
        }
        
        for (int i=0; i<numHP; i++) {
            if(numHP >= Math.pow(2, i)) {
                if(numHP < Math.pow(2, i+1)) {
                    attackCnt = (long)Math.pow(2, i + 1) - 1;
                    break;
                }
            } 
        }

        
        System.out.println(attackCnt);
    }
}
