/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner s=new Scanner(System.in);
		long n=s.nextLong();
		int p=(int)(Math.log(n)/Math.log(2));
		p++;
		System.out.println((long)(Math.pow(2,p)-1));
		
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
	public static void main (String[] args) {
		Scanner s=new Scanner(System.in);
		long n=s.nextLong();
		int p=(int)(Math.log(n)/Math.log(2));
		p++;
		System.out.println((long)(Math.pow(2,p)-1));
		
	}
} Main public static void main (String[] args) {
		Scanner s=new Scanner(System.in);
		long n=s.nextLong();
		int p=(int)(Math.log(n)/Math.log(2));
		p++;
		System.out.println((long)(Math.pow(2,p)-1));
		
	} main {
		Scanner s=new Scanner(System.in);
		long n=s.nextLong();
		int p=(int)(Math.log(n)/Math.log(2));
		p++;
		System.out.println((long)(Math.pow(2,p)-1));
		
	} Scanner s=new Scanner(System.in); s new Scanner(System.in) long n=s.nextLong(); n s.nextLong() s.nextLong s int p=(int)(Math.log(n)/Math.log(2)); p (int)(Math.log(n)/Math.log(2)) Math.log(n) Math.log Math n Math.log(2) Math.log Math 2 p++ p System.out.println((long)(Math.pow(2,p)-1)) System.out.println System.out System System.out (long)(Math.pow(2,p)-1) Math.pow(2,p) Math.pow Math 2 p 1 String[] args args public class Main {
	public static void main (String[] args) {
		Scanner s=new Scanner(System.in);
		long n=s.nextLong();
		int p=(int)(Math.log(n)/Math.log(2));
		p++;
		System.out.println((long)(Math.pow(2,p)-1));
		
	}
} public class Main {
	public static void main (String[] args) {
		Scanner s=new Scanner(System.in);
		long n=s.nextLong();
		int p=(int)(Math.log(n)/Math.log(2));
		p++;
		System.out.println((long)(Math.pow(2,p)-1));
		
	}
} Main
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner s=new Scanner(System.in);
		long n=s.nextLong();
		int p=(int)(Math.log(n)/Math.log(2));
		p++;
		System.out.println((long)(Math.pow(2,p)-1));
		
	}
}