import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long count = 0;
        long i = 1;
        while(h>0){
            h /= 2;
            count += i;
            i *=2;
        }
        System.out.println(count);
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long count = 0;
        long i = 1;
        while(h>0){
            h /= 2;
            count += i;
            i *=2;
        }
        System.out.println(count);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long count = 0;
        long i = 1;
        while(h>0){
            h /= 2;
            count += i;
            i *=2;
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long count = 0;
        long i = 1;
        while(h>0){
            h /= 2;
            count += i;
            i *=2;
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc long count = 0; count 0 long i = 1; i 1 while(h>0){
            h /= 2;
            count += i;
            i *=2;
        } h>0 h 0 {
            h /= 2;
            count += i;
            i *=2;
        } h /= 2 h 2 count += i count i i *=2 i 2 System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long count = 0;
        long i = 1;
        while(h>0){
            h /= 2;
            count += i;
            i *=2;
        }
        System.out.println(count);
    }
}