import java.io.*;
import java.util.*;
import java.math.*;
     
public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
      void preCalculate(long[] ar)
      {
        ar[0]=1L;
        for(int i=1 ; i<=40 ; i++)
        {
          ar[i] = (1L<<i)+ar[i-1];
          //System.out.println(ar[i]);
        }
        
      }
	    void solve(IO io, PrintWriter out)
	    {
           int i, j=0;
           	long n = io.nextLong();
          long[] pre = new long[41];
          preCalculate(pre);
          	for(i=0 ; i<64 ; i++)
            {
              	if(((1L<<i)&n)!=0)
                {
                  	j=i;
                  //out.println(j);
                }
            }
          	out.print(pre[j]);
	    }
    	
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	}
} import java.io.*; io.* java import java.util.*; util.* java import java.math.*; math.* java public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
      void preCalculate(long[] ar)
      {
        ar[0]=1L;
        for(int i=1 ; i<=40 ; i++)
        {
          ar[i] = (1L<<i)+ar[i-1];
          //System.out.println(ar[i]);
        }
        
      }
	    void solve(IO io, PrintWriter out)
	    {
           int i, j=0;
           	long n = io.nextLong();
          long[] pre = new long[41];
          preCalculate(pre);
          	for(i=0 ; i<64 ; i++)
            {
              	if(((1L<<i)&n)!=0)
                {
                  	j=i;
                  //out.println(j);
                }
            }
          	out.print(pre[j]);
	    }
    	
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	}
} Main public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	} main {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	} IO io = new IO(); io new IO() PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) Solver sr = new Solver(); sr new Solver() sr.solve(io,out) sr.solve sr io out out.flush() out.flush out out.close() out.close out String[] args args static class Solver
	{
      void preCalculate(long[] ar)
      {
        ar[0]=1L;
        for(int i=1 ; i<=40 ; i++)
        {
          ar[i] = (1L<<i)+ar[i-1];
          //System.out.println(ar[i]);
        }
        
      }
	    void solve(IO io, PrintWriter out)
	    {
           int i, j=0;
           	long n = io.nextLong();
          long[] pre = new long[41];
          preCalculate(pre);
          	for(i=0 ; i<64 ; i++)
            {
              	if(((1L<<i)&n)!=0)
                {
                  	j=i;
                  //out.println(j);
                }
            }
          	out.print(pre[j]);
	    }
    	
	} Solver void preCalculate(long[] ar)
      {
        ar[0]=1L;
        for(int i=1 ; i<=40 ; i++)
        {
          ar[i] = (1L<<i)+ar[i-1];
          //System.out.println(ar[i]);
        }
        
      } preCalculate {
        ar[0]=1L;
        for(int i=1 ; i<=40 ; i++)
        {
          ar[i] = (1L<<i)+ar[i-1];
          //System.out.println(ar[i]);
        }
        
      } ar[0]=1L ar[0] ar 0 1L for(int i=1 ; i<=40 ; i++)
        {
          ar[i] = (1L<<i)+ar[i-1];
          //System.out.println(ar[i]);
        } int i=1 ; int i=1 ; i 1 i<=40 i 40 i++ i++ i {
          ar[i] = (1L<<i)+ar[i-1];
          //System.out.println(ar[i]);
        } {
          ar[i] = (1L<<i)+ar[i-1];
          //System.out.println(ar[i]);
        } ar[i] = (1L<<i)+ar[i-1] ar[i] ar i (1L<<i)+ar[i-1] (1L<<i) 1L i ar[i-1] ar i-1 i 1 long[] ar ar void solve(IO io, PrintWriter out)
	    {
           int i, j=0;
           	long n = io.nextLong();
          long[] pre = new long[41];
          preCalculate(pre);
          	for(i=0 ; i<64 ; i++)
            {
              	if(((1L<<i)&n)!=0)
                {
                  	j=i;
                  //out.println(j);
                }
            }
          	out.print(pre[j]);
	    } solve {
           int i, j=0;
           	long n = io.nextLong();
          long[] pre = new long[41];
          preCalculate(pre);
          	for(i=0 ; i<64 ; i++)
            {
              	if(((1L<<i)&n)!=0)
                {
                  	j=i;
                  //out.println(j);
                }
            }
          	out.print(pre[j]);
	    } int i i j=0; j 0 long n = io.nextLong(); n io.nextLong() io.nextLong io long[] pre = new long[41]; pre new long[41] 41 preCalculate(pre) preCalculate pre for(i=0 ; i<64 ; i++)
            {
              	if(((1L<<i)&n)!=0)
                {
                  	j=i;
                  //out.println(j);
                }
            } i=0 ; i=0 i 0 i<64 i 64 i++ i++ i {
              	if(((1L<<i)&n)!=0)
                {
                  	j=i;
                  //out.println(j);
                }
            } {
              	if(((1L<<i)&n)!=0)
                {
                  	j=i;
                  //out.println(j);
                }
            } if(((1L<<i)&n)!=0)
                {
                  	j=i;
                  //out.println(j);
                } ((1L<<i)&n)!=0 ((1L<<i)&n) (1L<<i) 1L i n 0 {
                  	j=i;
                  //out.println(j);
                } j=i j i out.print(pre[j]) out.print out pre[j] pre j IO io io PrintWriter out out static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	} IO BufferedReader reader; reader StringTokenizer tokenizer; tokenizer public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            } IO {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            } reader = new BufferedReader(new InputStreamReader(System.in)) reader new BufferedReader(new InputStreamReader(System.in)) tokenizer = null tokenizer null public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } next {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } IOException e {
                    throw new RuntimeException(e);
                } throw new RuntimeException(e); new RuntimeException(e) {
                    tokenizer = new StringTokenizer(reader.readLine());
                } tokenizer = new StringTokenizer(reader.readLine()) tokenizer new StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        } nextLine {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        } String s=""; s "" try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } IOException e {
                    throw new RuntimeException(e);
                } throw new RuntimeException(e); new RuntimeException(e) {
                    s=reader.readLine();
                } s=reader.readLine() s reader.readLine() reader.readLine reader return s; s public int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble()
    	{
    		return Double.parseDouble(next());
    	} nextDouble {
    		return Double.parseDouble(next());
    	} return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
      void preCalculate(long[] ar)
      {
        ar[0]=1L;
        for(int i=1 ; i<=40 ; i++)
        {
          ar[i] = (1L<<i)+ar[i-1];
          //System.out.println(ar[i]);
        }
        
      }
	    void solve(IO io, PrintWriter out)
	    {
           int i, j=0;
           	long n = io.nextLong();
          long[] pre = new long[41];
          preCalculate(pre);
          	for(i=0 ; i<64 ; i++)
            {
              	if(((1L<<i)&n)!=0)
                {
                  	j=i;
                  //out.println(j);
                }
            }
          	out.print(pre[j]);
	    }
    	
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	}
} public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
      void preCalculate(long[] ar)
      {
        ar[0]=1L;
        for(int i=1 ; i<=40 ; i++)
        {
          ar[i] = (1L<<i)+ar[i-1];
          //System.out.println(ar[i]);
        }
        
      }
	    void solve(IO io, PrintWriter out)
	    {
           int i, j=0;
           	long n = io.nextLong();
          long[] pre = new long[41];
          preCalculate(pre);
          	for(i=0 ; i<64 ; i++)
            {
              	if(((1L<<i)&n)!=0)
                {
                  	j=i;
                  //out.println(j);
                }
            }
          	out.print(pre[j]);
	    }
    	
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	}
} Main
import java.io.*;
import java.util.*;
import java.math.*;
     
public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
      void preCalculate(long[] ar)
      {
        ar[0]=1L;
        for(int i=1 ; i<=40 ; i++)
        {
          ar[i] = (1L<<i)+ar[i-1];
          //System.out.println(ar[i]);
        }
        
      }
	    void solve(IO io, PrintWriter out)
	    {
           int i, j=0;
           	long n = io.nextLong();
          long[] pre = new long[41];
          preCalculate(pre);
          	for(i=0 ; i<64 ; i++)
            {
              	if(((1L<<i)&n)!=0)
                {
                  	j=i;
                  //out.println(j);
                }
            }
          	out.print(pre[j]);
	    }
    	
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	}
}