import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long tairyoku = Long.parseLong(sc.next());
		long kobetsuTairyoku = tairyoku;
		long count = 0;
		while(kobetsuTairyoku > 1) {
			kobetsuTairyoku = kobetsuTairyoku/2;
			count++;
		}
		long sumCount = 0;
		for(int i=0; i<=count; i++) {
			sumCount = (long) (sumCount + Math.pow(2, i));
		}
		System.out.println(sumCount);

	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long tairyoku = Long.parseLong(sc.next());
		long kobetsuTairyoku = tairyoku;
		long count = 0;
		while(kobetsuTairyoku > 1) {
			kobetsuTairyoku = kobetsuTairyoku/2;
			count++;
		}
		long sumCount = 0;
		for(int i=0; i<=count; i++) {
			sumCount = (long) (sumCount + Math.pow(2, i));
		}
		System.out.println(sumCount);

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long tairyoku = Long.parseLong(sc.next());
		long kobetsuTairyoku = tairyoku;
		long count = 0;
		while(kobetsuTairyoku > 1) {
			kobetsuTairyoku = kobetsuTairyoku/2;
			count++;
		}
		long sumCount = 0;
		for(int i=0; i<=count; i++) {
			sumCount = (long) (sumCount + Math.pow(2, i));
		}
		System.out.println(sumCount);

	} main {
		Scanner sc = new Scanner(System.in);
		long tairyoku = Long.parseLong(sc.next());
		long kobetsuTairyoku = tairyoku;
		long count = 0;
		while(kobetsuTairyoku > 1) {
			kobetsuTairyoku = kobetsuTairyoku/2;
			count++;
		}
		long sumCount = 0;
		for(int i=0; i<=count; i++) {
			sumCount = (long) (sumCount + Math.pow(2, i));
		}
		System.out.println(sumCount);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long tairyoku = Long.parseLong(sc.next()); tairyoku Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc long kobetsuTairyoku = tairyoku; kobetsuTairyoku tairyoku long count = 0; count 0 while(kobetsuTairyoku > 1) {
			kobetsuTairyoku = kobetsuTairyoku/2;
			count++;
		} kobetsuTairyoku > 1 kobetsuTairyoku 1 {
			kobetsuTairyoku = kobetsuTairyoku/2;
			count++;
		} kobetsuTairyoku = kobetsuTairyoku/2 kobetsuTairyoku kobetsuTairyoku/2 kobetsuTairyoku 2 count++ count long sumCount = 0; sumCount 0 for(int i=0; i<=count; i++) {
			sumCount = (long) (sumCount + Math.pow(2, i));
		} int i=0; int i=0; i 0 i<=count i count i++ i++ i {
			sumCount = (long) (sumCount + Math.pow(2, i));
		} {
			sumCount = (long) (sumCount + Math.pow(2, i));
		} sumCount = (long) (sumCount + Math.pow(2, i)) sumCount (long) (sumCount + Math.pow(2, i)) sumCount Math.pow(2, i) Math.pow Math 2 i System.out.println(sumCount) System.out.println System.out System System.out sumCount String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long tairyoku = Long.parseLong(sc.next());
		long kobetsuTairyoku = tairyoku;
		long count = 0;
		while(kobetsuTairyoku > 1) {
			kobetsuTairyoku = kobetsuTairyoku/2;
			count++;
		}
		long sumCount = 0;
		for(int i=0; i<=count; i++) {
			sumCount = (long) (sumCount + Math.pow(2, i));
		}
		System.out.println(sumCount);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long tairyoku = Long.parseLong(sc.next());
		long kobetsuTairyoku = tairyoku;
		long count = 0;
		while(kobetsuTairyoku > 1) {
			kobetsuTairyoku = kobetsuTairyoku/2;
			count++;
		}
		long sumCount = 0;
		for(int i=0; i<=count; i++) {
			sumCount = (long) (sumCount + Math.pow(2, i));
		}
		System.out.println(sumCount);

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long tairyoku = Long.parseLong(sc.next());
		long kobetsuTairyoku = tairyoku;
		long count = 0;
		while(kobetsuTairyoku > 1) {
			kobetsuTairyoku = kobetsuTairyoku/2;
			count++;
		}
		long sumCount = 0;
		for(int i=0; i<=count; i++) {
			sumCount = (long) (sumCount + Math.pow(2, i));
		}
		System.out.println(sumCount);

	}

}