import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long hp = sc.nextLong();
        System.out.println(hit(hp));
    }

    private static long hit(long hp) {
        return hp == 1 ? 1 : hit(hp / 2) * 2 + 1;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long hp = sc.nextLong();
        System.out.println(hit(hp));
    }

    private static long hit(long hp) {
        return hp == 1 ? 1 : hit(hp / 2) * 2 + 1;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long hp = sc.nextLong();
        System.out.println(hit(hp));
    } main {
        Scanner sc = new Scanner(System.in);
        long hp = sc.nextLong();
        System.out.println(hit(hp));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long hp = sc.nextLong(); hp sc.nextLong() sc.nextLong sc System.out.println(hit(hp)) System.out.println System.out System System.out hit(hp) hit hp String[] args args private static long hit(long hp) {
        return hp == 1 ? 1 : hit(hp / 2) * 2 + 1;
    } hit {
        return hp == 1 ? 1 : hit(hp / 2) * 2 + 1;
    } return hp == 1 ? 1 : hit(hp / 2) * 2 + 1; hp == 1 ? 1 : hit(hp / 2) * 2 + 1 hp == 1 hp 1 1 hit(hp / 2) * 2 + 1 hit(hp / 2) * 2 hit(hp / 2) hit hp / 2 hp 2 2 1 long hp hp public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long hp = sc.nextLong();
        System.out.println(hit(hp));
    }

    private static long hit(long hp) {
        return hp == 1 ? 1 : hit(hp / 2) * 2 + 1;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long hp = sc.nextLong();
        System.out.println(hit(hp));
    }

    private static long hit(long hp) {
        return hp == 1 ? 1 : hit(hp / 2) * 2 + 1;
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long hp = sc.nextLong();
        System.out.println(hit(hp));
    }

    private static long hit(long hp) {
        return hp == 1 ? 1 : hit(hp / 2) * 2 + 1;
    }
}