import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long powMonster = sc.nextLong();
		
		// 攻撃loop
		long attacks = attackMonsters(powMonster);
		
		log(attacks);
		sc.close();
	}
	
	static long attackMonsters(long powMonster) {
		long attacks = 0;
		if(powMonster == 1) {
			attacks=1;
		}
		else {
			long pow1;
			pow1 = (powMonster)/2;
			attacks = attackMonsters(pow1) * 2 + 1;
		}
		return attacks;
	}
	
	static void log(String s) {
		System.out.println(s);
	}

	static void log(int i) {
		System.out.println(i);
	}

	static void log(long i) {
		System.out.println(i);
	}

	static void log(double d) {
		System.out.printf("%.12f\n",d);
	}
	
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long powMonster = sc.nextLong();
		
		// 攻撃loop
		long attacks = attackMonsters(powMonster);
		
		log(attacks);
		sc.close();
	}
	
	static long attackMonsters(long powMonster) {
		long attacks = 0;
		if(powMonster == 1) {
			attacks=1;
		}
		else {
			long pow1;
			pow1 = (powMonster)/2;
			attacks = attackMonsters(pow1) * 2 + 1;
		}
		return attacks;
	}
	
	static void log(String s) {
		System.out.println(s);
	}

	static void log(int i) {
		System.out.println(i);
	}

	static void log(long i) {
		System.out.println(i);
	}

	static void log(double d) {
		System.out.printf("%.12f\n",d);
	}
	
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long powMonster = sc.nextLong();
		
		// 攻撃loop
		long attacks = attackMonsters(powMonster);
		
		log(attacks);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		
		long powMonster = sc.nextLong();
		
		// 攻撃loop
		long attacks = attackMonsters(powMonster);
		
		log(attacks);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long powMonster = sc.nextLong(); powMonster sc.nextLong() sc.nextLong sc long attacks = attackMonsters(powMonster); attacks attackMonsters(powMonster) attackMonsters powMonster log(attacks) log attacks sc.close() sc.close sc String[] args args static long attackMonsters(long powMonster) {
		long attacks = 0;
		if(powMonster == 1) {
			attacks=1;
		}
		else {
			long pow1;
			pow1 = (powMonster)/2;
			attacks = attackMonsters(pow1) * 2 + 1;
		}
		return attacks;
	} attackMonsters {
		long attacks = 0;
		if(powMonster == 1) {
			attacks=1;
		}
		else {
			long pow1;
			pow1 = (powMonster)/2;
			attacks = attackMonsters(pow1) * 2 + 1;
		}
		return attacks;
	} long attacks = 0; attacks 0 if(powMonster == 1) {
			attacks=1;
		}
		else {
			long pow1;
			pow1 = (powMonster)/2;
			attacks = attackMonsters(pow1) * 2 + 1;
		} powMonster == 1 powMonster 1 {
			attacks=1;
		} attacks=1 attacks 1 {
			long pow1;
			pow1 = (powMonster)/2;
			attacks = attackMonsters(pow1) * 2 + 1;
		} long pow1; pow1 pow1 = (powMonster)/2 pow1 (powMonster)/2 (powMonster) 2 attacks = attackMonsters(pow1) * 2 + 1 attacks attackMonsters(pow1) * 2 + 1 attackMonsters(pow1) * 2 attackMonsters(pow1) attackMonsters pow1 2 1 return attacks; attacks long powMonster powMonster static void log(String s) {
		System.out.println(s);
	} log {
		System.out.println(s);
	} System.out.println(s) System.out.println System.out System System.out s String s s static void log(int i) {
		System.out.println(i);
	} log {
		System.out.println(i);
	} System.out.println(i) System.out.println System.out System System.out i int i i static void log(long i) {
		System.out.println(i);
	} log {
		System.out.println(i);
	} System.out.println(i) System.out.println System.out System System.out i long i i static void log(double d) {
		System.out.printf("%.12f\n",d);
	} log {
		System.out.printf("%.12f\n",d);
	} System.out.printf("%.12f\n",d) System.out.printf System.out System System.out "%.12f\n" d double d d public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long powMonster = sc.nextLong();
		
		// 攻撃loop
		long attacks = attackMonsters(powMonster);
		
		log(attacks);
		sc.close();
	}
	
	static long attackMonsters(long powMonster) {
		long attacks = 0;
		if(powMonster == 1) {
			attacks=1;
		}
		else {
			long pow1;
			pow1 = (powMonster)/2;
			attacks = attackMonsters(pow1) * 2 + 1;
		}
		return attacks;
	}
	
	static void log(String s) {
		System.out.println(s);
	}

	static void log(int i) {
		System.out.println(i);
	}

	static void log(long i) {
		System.out.println(i);
	}

	static void log(double d) {
		System.out.printf("%.12f\n",d);
	}
	
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long powMonster = sc.nextLong();
		
		// 攻撃loop
		long attacks = attackMonsters(powMonster);
		
		log(attacks);
		sc.close();
	}
	
	static long attackMonsters(long powMonster) {
		long attacks = 0;
		if(powMonster == 1) {
			attacks=1;
		}
		else {
			long pow1;
			pow1 = (powMonster)/2;
			attacks = attackMonsters(pow1) * 2 + 1;
		}
		return attacks;
	}
	
	static void log(String s) {
		System.out.println(s);
	}

	static void log(int i) {
		System.out.println(i);
	}

	static void log(long i) {
		System.out.println(i);
	}

	static void log(double d) {
		System.out.printf("%.12f\n",d);
	}
	
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long powMonster = sc.nextLong();
		
		// 攻撃loop
		long attacks = attackMonsters(powMonster);
		
		log(attacks);
		sc.close();
	}
	
	static long attackMonsters(long powMonster) {
		long attacks = 0;
		if(powMonster == 1) {
			attacks=1;
		}
		else {
			long pow1;
			pow1 = (powMonster)/2;
			attacks = attackMonsters(pow1) * 2 + 1;
		}
		return attacks;
	}
	
	static void log(String s) {
		System.out.println(s);
	}

	static void log(int i) {
		System.out.println(i);
	}

	static void log(long i) {
		System.out.println(i);
	}

	static void log(double d) {
		System.out.printf("%.12f\n",d);
	}
	
}
