import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long cnt = 0;
        long ans = 0;
        
        while(N!=0){
            N/=2;
            ans = ans + (long)Math.pow(2,cnt);
            cnt++;
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long cnt = 0;
        long ans = 0;
        
        while(N!=0){
            N/=2;
            ans = ans + (long)Math.pow(2,cnt);
            cnt++;
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long cnt = 0;
        long ans = 0;
        
        while(N!=0){
            N/=2;
            ans = ans + (long)Math.pow(2,cnt);
            cnt++;
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long cnt = 0;
        long ans = 0;
        
        while(N!=0){
            N/=2;
            ans = ans + (long)Math.pow(2,cnt);
            cnt++;
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long N = sc.nextLong(); N sc.nextLong() sc.nextLong sc long cnt = 0; cnt 0 long ans = 0; ans 0 while(N!=0){
            N/=2;
            ans = ans + (long)Math.pow(2,cnt);
            cnt++;
        } N!=0 N 0 {
            N/=2;
            ans = ans + (long)Math.pow(2,cnt);
            cnt++;
        } N/=2 N 2 ans = ans + (long)Math.pow(2,cnt) ans ans + (long)Math.pow(2,cnt) ans (long)Math.pow(2,cnt) Math.pow Math 2 cnt cnt++ cnt System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long cnt = 0;
        long ans = 0;
        
        while(N!=0){
            N/=2;
            ans = ans + (long)Math.pow(2,cnt);
            cnt++;
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long cnt = 0;
        long ans = 0;
        
        while(N!=0){
            N/=2;
            ans = ans + (long)Math.pow(2,cnt);
            cnt++;
        }
        System.out.println(ans);
    }
} Main
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long cnt = 0;
        long ans = 0;
        
        while(N!=0){
            N/=2;
            ans = ans + (long)Math.pow(2,cnt);
            cnt++;
        }
        System.out.println(ans);
    }
}