
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        int height = (int) Math.floor (Math.log10(h) / Math.log10(2));

        //System.out.println(height);
        height+=1;

        long res = 0;
        for(int i = 0; i< height; i++){
            res += Math.pow(2, i);
        }
        System.out.println(res);
    }



    public static boolean isPower(long n) {
        if (n < 1)
            return false;
        int i = 1;
        while (i <= n) {
            if (i == n)
                return true;
            i <<= 1;

        }
        return false;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        int height = (int) Math.floor (Math.log10(h) / Math.log10(2));

        //System.out.println(height);
        height+=1;

        long res = 0;
        for(int i = 0; i< height; i++){
            res += Math.pow(2, i);
        }
        System.out.println(res);
    }



    public static boolean isPower(long n) {
        if (n < 1)
            return false;
        int i = 1;
        while (i <= n) {
            if (i == n)
                return true;
            i <<= 1;

        }
        return false;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        int height = (int) Math.floor (Math.log10(h) / Math.log10(2));

        //System.out.println(height);
        height+=1;

        long res = 0;
        for(int i = 0; i< height; i++){
            res += Math.pow(2, i);
        }
        System.out.println(res);
    } main {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        int height = (int) Math.floor (Math.log10(h) / Math.log10(2));

        //System.out.println(height);
        height+=1;

        long res = 0;
        for(int i = 0; i< height; i++){
            res += Math.pow(2, i);
        }
        System.out.println(res);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc int height = (int) Math.floor (Math.log10(h) / Math.log10(2)); height (int) Math.floor (Math.log10(h) / Math.log10(2)) Math.floor Math Math.log10(h) / Math.log10(2) Math.log10(h) Math.log10 Math h Math.log10(2) Math.log10 Math 2 height+=1 height 1 long res = 0; res 0 for(int i = 0; i< height; i++){
            res += Math.pow(2, i);
        } int i = 0; int i = 0; i 0 i< height i height i++ i++ i {
            res += Math.pow(2, i);
        } {
            res += Math.pow(2, i);
        } res += Math.pow(2, i) res Math.pow(2, i) Math.pow Math 2 i System.out.println(res) System.out.println System.out System System.out res String[] args args public static boolean isPower(long n) {
        if (n < 1)
            return false;
        int i = 1;
        while (i <= n) {
            if (i == n)
                return true;
            i <<= 1;

        }
        return false;
    } isPower {
        if (n < 1)
            return false;
        int i = 1;
        while (i <= n) {
            if (i == n)
                return true;
            i <<= 1;

        }
        return false;
    } if (n < 1)
            return false; n < 1 n 1 return false; false int i = 1; i 1 while (i <= n) {
            if (i == n)
                return true;
            i <<= 1;

        } i <= n i n {
            if (i == n)
                return true;
            i <<= 1;

        } if (i == n)
                return true; i == n i n return true; true i <<= 1 i 1 return false; false long n n public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        int height = (int) Math.floor (Math.log10(h) / Math.log10(2));

        //System.out.println(height);
        height+=1;

        long res = 0;
        for(int i = 0; i< height; i++){
            res += Math.pow(2, i);
        }
        System.out.println(res);
    }



    public static boolean isPower(long n) {
        if (n < 1)
            return false;
        int i = 1;
        while (i <= n) {
            if (i == n)
                return true;
            i <<= 1;

        }
        return false;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        int height = (int) Math.floor (Math.log10(h) / Math.log10(2));

        //System.out.println(height);
        height+=1;

        long res = 0;
        for(int i = 0; i< height; i++){
            res += Math.pow(2, i);
        }
        System.out.println(res);
    }



    public static boolean isPower(long n) {
        if (n < 1)
            return false;
        int i = 1;
        while (i <= n) {
            if (i == n)
                return true;
            i <<= 1;

        }
        return false;
    }
} Main

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        int height = (int) Math.floor (Math.log10(h) / Math.log10(2));

        //System.out.println(height);
        height+=1;

        long res = 0;
        for(int i = 0; i< height; i++){
            res += Math.pow(2, i);
        }
        System.out.println(res);
    }



    public static boolean isPower(long n) {
        if (n < 1)
            return false;
        int i = 1;
        while (i <= n) {
            if (i == n)
                return true;
            i <<= 1;

        }
        return false;
    }
}
