1. 


/*
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #10254 - The Priest Mathematician
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1195
*
* @author Lermer Florian
* @author Sayli Hidir
* @author Taskin Umut
* @version 0.0.1.5.1.0, 05/25/2009
*
* Status : Accepted
* Runtime: 1.848
*
* Special Thanks to Group Tschannerl J. & Leib D.
*
*/

//import java.io.Writer;
//import java.io.File;
//import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.math.BigInteger;

public class Main {

public static void main(String... args) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringBuilder out=new StringBuilder();
String line=br.readLine();
while(line!=null)
{
int discs = Integer.parseInt(line);
if(discs<=1)
{
out.append(((discs==1)?"1":"0")+"\n");
line=br.readLine();
continue;
}
BigInteger result = new BigInteger("0");
int sum=0;
int i=1;
while(sum<discs)
{
sum+=i;
i+=(sum<discs)?1:0;
}
result=new BigInteger("2").pow(i-1).multiply(new BigInteger(""+(i-(sum-discs))));
for (int x=1;x<=i-1;x++)
result=result.add(new BigInteger("2").pow(x-1).multiply(new BigInteger(""+x)));

out.append(result.toString()+"\n");
line=br.readLine();

}
out.delete(out.length()-1,out.length());
System.out.println(out.toString());
// Writer w=new FileWriter(new File("test.txt"));
// w.write(out.toString());
// w.flush();
// w.close();

}

}