import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		long hp = sc.nextLong();
		long attackCount = 0;
		long monsterCount = 1;
		while(true) {
			if(hp == 1) {
				attackCount += monsterCount;
				break;
			}
			attackCount += monsterCount;
			hp /= 2;
			monsterCount *=2;
		}
		System.out.println(attackCount);
	}
} 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();
		long attackCount = 0;
		long monsterCount = 1;
		while(true) {
			if(hp == 1) {
				attackCount += monsterCount;
				break;
			}
			attackCount += monsterCount;
			hp /= 2;
			monsterCount *=2;
		}
		System.out.println(attackCount);
	}
} Main public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		long hp = sc.nextLong();
		long attackCount = 0;
		long monsterCount = 1;
		while(true) {
			if(hp == 1) {
				attackCount += monsterCount;
				break;
			}
			attackCount += monsterCount;
			hp /= 2;
			monsterCount *=2;
		}
		System.out.println(attackCount);
	} main {


		Scanner sc = new Scanner(System.in);
		long hp = sc.nextLong();
		long attackCount = 0;
		long monsterCount = 1;
		while(true) {
			if(hp == 1) {
				attackCount += monsterCount;
				break;
			}
			attackCount += monsterCount;
			hp /= 2;
			monsterCount *=2;
		}
		System.out.println(attackCount);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long hp = sc.nextLong(); hp sc.nextLong() sc.nextLong sc long attackCount = 0; attackCount 0 long monsterCount = 1; monsterCount 1 while(true) {
			if(hp == 1) {
				attackCount += monsterCount;
				break;
			}
			attackCount += monsterCount;
			hp /= 2;
			monsterCount *=2;
		} true {
			if(hp == 1) {
				attackCount += monsterCount;
				break;
			}
			attackCount += monsterCount;
			hp /= 2;
			monsterCount *=2;
		} if(hp == 1) {
				attackCount += monsterCount;
				break;
			} hp == 1 hp 1 {
				attackCount += monsterCount;
				break;
			} attackCount += monsterCount attackCount monsterCount break; attackCount += monsterCount attackCount monsterCount hp /= 2 hp 2 monsterCount *=2 monsterCount 2 System.out.println(attackCount) System.out.println System.out System System.out attackCount String[] args args public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		long hp = sc.nextLong();
		long attackCount = 0;
		long monsterCount = 1;
		while(true) {
			if(hp == 1) {
				attackCount += monsterCount;
				break;
			}
			attackCount += monsterCount;
			hp /= 2;
			monsterCount *=2;
		}
		System.out.println(attackCount);
	}
} public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		long hp = sc.nextLong();
		long attackCount = 0;
		long monsterCount = 1;
		while(true) {
			if(hp == 1) {
				attackCount += monsterCount;
				break;
			}
			attackCount += monsterCount;
			hp /= 2;
			monsterCount *=2;
		}
		System.out.println(attackCount);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		long hp = sc.nextLong();
		long attackCount = 0;
		long monsterCount = 1;
		while(true) {
			if(hp == 1) {
				attackCount += monsterCount;
				break;
			}
			attackCount += monsterCount;
			hp /= 2;
			monsterCount *=2;
		}
		System.out.println(attackCount);
	}
}