import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long M_hp = sc.nextLong();
		long count = 1;
		long attack = 1;
		int flg = 0;
		if(M_hp == 1) {
		}else {

			for(;;) {
				M_hp = M_hp/2;
				if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				}

			}
		}
			System.out.println(attack);
		}
	} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long M_hp = sc.nextLong();
		long count = 1;
		long attack = 1;
		int flg = 0;
		if(M_hp == 1) {
		}else {

			for(;;) {
				M_hp = M_hp/2;
				if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				}

			}
		}
			System.out.println(attack);
		}
	} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long M_hp = sc.nextLong();
		long count = 1;
		long attack = 1;
		int flg = 0;
		if(M_hp == 1) {
		}else {

			for(;;) {
				M_hp = M_hp/2;
				if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				}

			}
		}
			System.out.println(attack);
		} main {
		Scanner sc = new Scanner(System.in);

		long M_hp = sc.nextLong();
		long count = 1;
		long attack = 1;
		int flg = 0;
		if(M_hp == 1) {
		}else {

			for(;;) {
				M_hp = M_hp/2;
				if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				}

			}
		}
			System.out.println(attack);
		} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long M_hp = sc.nextLong(); M_hp sc.nextLong() sc.nextLong sc long count = 1; count 1 long attack = 1; attack 1 int flg = 0; flg 0 if(M_hp == 1) {
		}else {

			for(;;) {
				M_hp = M_hp/2;
				if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				}

			}
		} M_hp == 1 M_hp 1 {
		} {

			for(;;) {
				M_hp = M_hp/2;
				if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				}

			}
		} for(;;) {
				M_hp = M_hp/2;
				if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				}

			} ; {
				M_hp = M_hp/2;
				if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				}

			} {
				M_hp = M_hp/2;
				if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				}

			} M_hp = M_hp/2 M_hp M_hp/2 M_hp 2 if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				} M_hp < 2 M_hp 2 {
					count = count*2;
					attack = attack + count;
					break;
				} count = count*2 count count*2 count 2 attack = attack + count attack attack + count attack count break; {
					count = count*2;
					attack = attack + count;
				} count = count*2 count count*2 count 2 attack = attack + count attack attack + count attack count System.out.println(attack) System.out.println System.out System System.out attack String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long M_hp = sc.nextLong();
		long count = 1;
		long attack = 1;
		int flg = 0;
		if(M_hp == 1) {
		}else {

			for(;;) {
				M_hp = M_hp/2;
				if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				}

			}
		}
			System.out.println(attack);
		}
	} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long M_hp = sc.nextLong();
		long count = 1;
		long attack = 1;
		int flg = 0;
		if(M_hp == 1) {
		}else {

			for(;;) {
				M_hp = M_hp/2;
				if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				}

			}
		}
			System.out.println(attack);
		}
	} Main
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long M_hp = sc.nextLong();
		long count = 1;
		long attack = 1;
		int flg = 0;
		if(M_hp == 1) {
		}else {

			for(;;) {
				M_hp = M_hp/2;
				if(M_hp < 2) {
					count = count*2;
					attack = attack + count;
					break;
				}else {
					count = count*2;
					attack = attack + count;
				}

			}
		}
			System.out.println(attack);
		}
	}
