import java.math.*;
import java.util.*;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			long h = sc.nextLong();
			int count =0;
			long sumattack = 0;
			
			for(;;) {
				count++;
				
				h = h/2;
				sumattack += Math.pow(2, (count-1));
				if(h==0) {
					System.out.println(sumattack);
					return; 
				}
				
				
			}
			
			
		}

	} import java.math.*; math.* java import java.util.*; util.* java public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			long h = sc.nextLong();
			int count =0;
			long sumattack = 0;
			
			for(;;) {
				count++;
				
				h = h/2;
				sumattack += Math.pow(2, (count-1));
				if(h==0) {
					System.out.println(sumattack);
					return; 
				}
				
				
			}
			
			
		}

	} Main public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			long h = sc.nextLong();
			int count =0;
			long sumattack = 0;
			
			for(;;) {
				count++;
				
				h = h/2;
				sumattack += Math.pow(2, (count-1));
				if(h==0) {
					System.out.println(sumattack);
					return; 
				}
				
				
			}
			
			
		} main {

			Scanner sc = new Scanner(System.in);
			long h = sc.nextLong();
			int count =0;
			long sumattack = 0;
			
			for(;;) {
				count++;
				
				h = h/2;
				sumattack += Math.pow(2, (count-1));
				if(h==0) {
					System.out.println(sumattack);
					return; 
				}
				
				
			}
			
			
		} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long h = sc.nextLong(); h sc.nextLong() sc.nextLong sc int count =0; count 0 long sumattack = 0; sumattack 0 for(;;) {
				count++;
				
				h = h/2;
				sumattack += Math.pow(2, (count-1));
				if(h==0) {
					System.out.println(sumattack);
					return; 
				}
				
				
			} ; {
				count++;
				
				h = h/2;
				sumattack += Math.pow(2, (count-1));
				if(h==0) {
					System.out.println(sumattack);
					return; 
				}
				
				
			} {
				count++;
				
				h = h/2;
				sumattack += Math.pow(2, (count-1));
				if(h==0) {
					System.out.println(sumattack);
					return; 
				}
				
				
			} count++ count h = h/2 h h/2 h 2 sumattack += Math.pow(2, (count-1)) sumattack Math.pow(2, (count-1)) Math.pow Math 2 (count-1) count 1 if(h==0) {
					System.out.println(sumattack);
					return; 
				} h==0 h 0 {
					System.out.println(sumattack);
					return; 
				} System.out.println(sumattack) System.out.println System.out System System.out sumattack return; String[] args args public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			long h = sc.nextLong();
			int count =0;
			long sumattack = 0;
			
			for(;;) {
				count++;
				
				h = h/2;
				sumattack += Math.pow(2, (count-1));
				if(h==0) {
					System.out.println(sumattack);
					return; 
				}
				
				
			}
			
			
		}

	} public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			long h = sc.nextLong();
			int count =0;
			long sumattack = 0;
			
			for(;;) {
				count++;
				
				h = h/2;
				sumattack += Math.pow(2, (count-1));
				if(h==0) {
					System.out.println(sumattack);
					return; 
				}
				
				
			}
			
			
		}

	} Main
import java.math.*;
import java.util.*;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			long h = sc.nextLong();
			int count =0;
			long sumattack = 0;
			
			for(;;) {
				count++;
				
				h = h/2;
				sumattack += Math.pow(2, (count-1));
				if(h==0) {
					System.out.println(sumattack);
					return; 
				}
				
				
			}
			
			
		}

	}