import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.next();
        long n = Long.parseLong(line);
        for (int b = 1; b < 63; b <<= 1) {
            n |= (n >>> b);
        }
        System.out.println(n);
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.next();
        long n = Long.parseLong(line);
        for (int b = 1; b < 63; b <<= 1) {
            n |= (n >>> b);
        }
        System.out.println(n);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.next();
        long n = Long.parseLong(line);
        for (int b = 1; b < 63; b <<= 1) {
            n |= (n >>> b);
        }
        System.out.println(n);
    } main {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.next();
        long n = Long.parseLong(line);
        for (int b = 1; b < 63; b <<= 1) {
            n |= (n >>> b);
        }
        System.out.println(n);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String line = scanner.next(); line scanner.next() scanner.next scanner long n = Long.parseLong(line); n Long.parseLong(line) Long.parseLong Long line for (int b = 1; b < 63; b <<= 1) {
            n |= (n >>> b);
        } int b = 1; int b = 1; b 1 b < 63 b 63 b <<= 1 b <<= 1 b 1 {
            n |= (n >>> b);
        } {
            n |= (n >>> b);
        } n |= (n >>> b) n (n >>> b) n b System.out.println(n) System.out.println System.out System System.out n String[] args args
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.next();
        long n = Long.parseLong(line);
        for (int b = 1; b < 63; b <<= 1) {
            n |= (n >>> b);
        }
        System.out.println(n);
    }
}