import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long count = 0;
        while(n>1) {
            n = n / 2;
            count++;
        }
        long answer = 0;
        for (int i = 0; i <= count; i++){
            answer += Math.pow(2,i);
        }
        System.out.println(answer);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Comparator; Comparator java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util import java.util.stream.Collectors; Collectors java.util.stream public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long count = 0;
        while(n>1) {
            n = n / 2;
            count++;
        }
        long answer = 0;
        for (int i = 0; i <= count; i++){
            answer += Math.pow(2,i);
        }
        System.out.println(answer);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long count = 0;
        while(n>1) {
            n = n / 2;
            count++;
        }
        long answer = 0;
        for (int i = 0; i <= count; i++){
            answer += Math.pow(2,i);
        }
        System.out.println(answer);
    } main {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long count = 0;
        while(n>1) {
            n = n / 2;
            count++;
        }
        long answer = 0;
        for (int i = 0; i <= count; i++){
            answer += Math.pow(2,i);
        }
        System.out.println(answer);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) long n = scanner.nextLong(); n scanner.nextLong() scanner.nextLong scanner long count = 0; count 0 while(n>1) {
            n = n / 2;
            count++;
        } n>1 n 1 {
            n = n / 2;
            count++;
        } n = n / 2 n n / 2 n 2 count++ count long answer = 0; answer 0 for (int i = 0; i <= count; i++){
            answer += Math.pow(2,i);
        } int i = 0; int i = 0; i 0 i <= count i count i++ i++ i {
            answer += Math.pow(2,i);
        } {
            answer += Math.pow(2,i);
        } answer += Math.pow(2,i) answer Math.pow(2,i) Math.pow Math 2 i System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long count = 0;
        while(n>1) {
            n = n / 2;
            count++;
        }
        long answer = 0;
        for (int i = 0; i <= count; i++){
            answer += Math.pow(2,i);
        }
        System.out.println(answer);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long count = 0;
        while(n>1) {
            n = n / 2;
            count++;
        }
        long answer = 0;
        for (int i = 0; i <= count; i++){
            answer += Math.pow(2,i);
        }
        System.out.println(answer);
    }
} Main
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long count = 0;
        while(n>1) {
            n = n / 2;
            count++;
        }
        long answer = 0;
        for (int i = 0; i <= count; i++){
            answer += Math.pow(2,i);
        }
        System.out.println(answer);
    }
}
