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

public class Main {
    
    static long attack_number(long h){
        if(h == 1L) return 1;
        return 2 * attack_number(h / 2L) + 1;
    }
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in1 = br.readLine().split(" ");
        long H = Long.parseLong(in1[0]);
        br.close();
        
        System.out.println(attack_number(H));
    }
} import java.util.*; util.* java import java.util.stream.*; stream.* java.util import java.io.*; io.* java public class Main {
    
    static long attack_number(long h){
        if(h == 1L) return 1;
        return 2 * attack_number(h / 2L) + 1;
    }
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in1 = br.readLine().split(" ");
        long H = Long.parseLong(in1[0]);
        br.close();
        
        System.out.println(attack_number(H));
    }
} Main static long attack_number(long h){
        if(h == 1L) return 1;
        return 2 * attack_number(h / 2L) + 1;
    } attack_number {
        if(h == 1L) return 1;
        return 2 * attack_number(h / 2L) + 1;
    } if(h == 1L) return 1; h == 1L h 1L return 1; 1 return 2 * attack_number(h / 2L) + 1; 2 * attack_number(h / 2L) + 1 2 * attack_number(h / 2L) 2 attack_number(h / 2L) attack_number h / 2L h 2L 1 long h h public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in1 = br.readLine().split(" ");
        long H = Long.parseLong(in1[0]);
        br.close();
        
        System.out.println(attack_number(H));
    } main {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in1 = br.readLine().split(" ");
        long H = Long.parseLong(in1[0]);
        br.close();
        
        System.out.println(attack_number(H));
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] in1 = br.readLine().split(" "); in1 br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " long H = Long.parseLong(in1[0]); H Long.parseLong(in1[0]) Long.parseLong Long in1[0] in1 0 br.close() br.close br System.out.println(attack_number(H)) System.out.println System.out System System.out attack_number(H) attack_number H String[] args args public class Main {
    
    static long attack_number(long h){
        if(h == 1L) return 1;
        return 2 * attack_number(h / 2L) + 1;
    }
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in1 = br.readLine().split(" ");
        long H = Long.parseLong(in1[0]);
        br.close();
        
        System.out.println(attack_number(H));
    }
} public class Main {
    
    static long attack_number(long h){
        if(h == 1L) return 1;
        return 2 * attack_number(h / 2L) + 1;
    }
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in1 = br.readLine().split(" ");
        long H = Long.parseLong(in1[0]);
        br.close();
        
        System.out.println(attack_number(H));
    }
} Main
import java.util.*;
import java.util.stream.*;
import java.io.*;

public class Main {
    
    static long attack_number(long h){
        if(h == 1L) return 1;
        return 2 * attack_number(h / 2L) + 1;
    }
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in1 = br.readLine().split(" ");
        long H = Long.parseLong(in1[0]);
        br.close();
        
        System.out.println(attack_number(H));
    }
}