import java.io.*;
import java.util.*;

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    // no self-loop or multiple edges
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        sc.close();
        long n = 1;
        long ans = 0;
        while(H>0){
            ans += n;
            H /= 2;
            n *= 2;
        }
        return ans;
    }
}
 import java.io.*; io.* java import java.util.*; util.* java public class Main {
    PrintWriter out = new PrintWriter(System.out);
    // no self-loop or multiple edges
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        sc.close();
        long n = 1;
        long ans = 0;
        while(H>0){
            ans += n;
            H /= 2;
            n *= 2;
        }
        return ans;
    }
} Main PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) // no self-loop or multiple edges
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    } main {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    } Main main = new Main(); main new Main() System.out.println(main.solve()) System.out.println System.out System System.out main.solve() main.solve main String[] args args long solve(){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        sc.close();
        long n = 1;
        long ans = 0;
        while(H>0){
            ans += n;
            H /= 2;
            n *= 2;
        }
        return ans;
    } solve {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        sc.close();
        long n = 1;
        long ans = 0;
        while(H>0){
            ans += n;
            H /= 2;
            n *= 2;
        }
        return ans;
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long H = sc.nextLong(); H sc.nextLong() sc.nextLong sc sc.close() sc.close sc long n = 1; n 1 long ans = 0; ans 0 while(H>0){
            ans += n;
            H /= 2;
            n *= 2;
        } H>0 H 0 {
            ans += n;
            H /= 2;
            n *= 2;
        } ans += n ans n H /= 2 H 2 n *= 2 n 2 return ans; ans public class Main {
    PrintWriter out = new PrintWriter(System.out);
    // no self-loop or multiple edges
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        sc.close();
        long n = 1;
        long ans = 0;
        while(H>0){
            ans += n;
            H /= 2;
            n *= 2;
        }
        return ans;
    }
} public class Main {
    PrintWriter out = new PrintWriter(System.out);
    // no self-loop or multiple edges
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        sc.close();
        long n = 1;
        long ans = 0;
        while(H>0){
            ans += n;
            H /= 2;
            n *= 2;
        }
        return ans;
    }
} Main
import java.io.*;
import java.util.*;

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    // no self-loop or multiple edges
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        sc.close();
        long n = 1;
        long ans = 0;
        while(H>0){
            ans += n;
            H /= 2;
            n *= 2;
        }
        return ans;
    }
}

