//vi khuan

var
  n, ans: longint;

begin
  readln(n);
  while n > 0 do
    begin
      ans:= ans + n mod 2;
      n:= n div 2;
    end;
  writeln(ans);
end.

{$H+}
var k,n,a,b,c,x:longint;
    s,s1:string;
begin
{assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);  }
readln(n);
while n<>0 do
  begin
    b:=n mod 2;
    str(b,s1);
    if s1='1' then inc(k);
    s:=s1+s;
    n:=n div 2;
  end;
writeln(k);
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils, Math;

var
  n, i, s : integer;
begin
  readln(n);
  s:=0;
  while n>=1 do begin
  s:=s + n mod 2;
  n:=n div 2;
  end;
  writeln(s);
  readln;
end.

var
  a, x: integer;

begin
  read(x);
  while x > 1 do
  begin
    if x mod 2 = 0 then x := x div 2
    else begin x := x - 1; a := a + 1; end;

  end;
  a := a + 1;
  write(a);
end.

var
 x,i : longint ;

begin
 readln (x) ;
 i := 1 ;
 while x <> 1 do
 begin
 if x mod 2 = 0 then
  x := x div 2
 else
  begin
  dec(x) ;
  inc(i) ;
  end;
 end;
 writeln (i) ;
end.

var
    x,cnt:integer;
begin
    Read(x);
    cnt:=0;
    while x>0 do begin
        if x mod 2 = 1 then begin
            x:=x-1;
            inc(cnt);
        end;
        x:=x div 2;
    end;
    writeln(cnt);
end.

var k,s,x:int64;

begin
 readln(x);
 k:=1;
 s:=1;
 while s<>x do
 begin
  s:=1;

  while s<x do
   s:=s*2;
  if s=x then  break

             else
              begin
               k:=k+1;
               if s+1=x then  break;
               s:=s div 2;
               dec(x,s);
              end;
 end;
 writeln(k);
end.

program Ad;

{$APPTYPE CONSOLE}

uses
  SysUtils,Math;

var
   a,b:array[1..10] of integer;
   s,n,k :int64;
   i:integer;
begin
   readln(n);
   s:=1;
   for i:=1 to 33 do
   begin
      if(s=n) then
      begin
         writeln(1);
         exit;
      end;
      s:=s*2;
   end;
   k:=1;
   while(n>1) do
   begin
      if(n mod 2<>0) then inc(k);
      n:=n div 2;
   end;
   writeln(k);
   readln;
   readln;
end.

var
  ans, n, i: longint;
  f: array[0..30] of longint;

begin
  //assign(input, 'input.txt'); reset(input);
  readln(n);
  f[0] := 1;
  for i := 1 to 30 do f[i] := f[i - 1] shl 1;
  ans := 0;
  for i := 30 downto 0 do
      if n >= f[i] then
        begin
          dec(n, f[i]);
          inc(ans);
        end;
  writeln(ans);
end.

var
 N,k:longint;

begin
   Read(N);
   while N > 0 do
    begin
      if N and 1 = 1 then Inc(k);
      N:=N shr 1;
    end;
   write(k);
end.

var
n,ans:longint;
begin
readln(n);
while (n>0) do begin
    if n mod 2 = 1 then begin
    inc(ans);
    dec(n)
    end
    else
    n:=n div 2;
end;
writeln(ans);
end.

program Ad;

{$APPTYPE CONSOLE}

uses
  SysUtils,Math;

var
   a,b:array[1..10] of integer;
   s,n,k :int64;
   i:integer;
begin
   readln(n);
   s:=1;
   for i:=1 to 33 do
   begin
      if(s=n) then
      begin
         writeln(1);
         exit;
      end;
  {  if(s*2>n) then
      begin
         k:=(min(1+n-s,n));
         break;
      end; }
      s:=s*2;
   end;
   k:=1;
   while(n>1) do
   begin
      if(n mod 2<>0) then inc(k);
      n:=n div 2;
   end;
   writeln(k);
   readln;
   readln;
end.

var
 x:integer;
 t:integer;

procedure check;
begin
if (x mod 2)=1 then
  begin
  inc(t);
  dec(x);
  end
else
  begin
  x:=x div 2;
  end;
end;

begin
readln(x);
t:=1;
while x>1 do check;
writeln(t);
readln;
end.

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  SysUtils,math;

var
  m,i,n,k,l,j,t:Integer;
  str,str1:string;
  a:array of Integer;
  bol:Boolean;

begin
  Readln(n);
  m:=1;
  k:=1;
  repeat
    if k*2-n>0 then
    begin
      n:=n-k;
      if n>0 then
      begin
        k:=1;
        inc (m)
      end;
    end
    else k:=k*2;

  until n=0;

  Writeln(m);

  Readln(n);
end.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='qc';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,a,aa:array[0..1000000]of longint;
    qc,he:array[0..2014,0..2014]of longint;
    s,ss,sss,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    w,nt,ii,jj,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3:longint;
    nn,mm,kk,u,v,res,cur,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;
    ccc:char;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  read(n);
  res:=0;
  while n>0 do
    begin
    if odd(n) then begin inc(res); dec(n); end;
    n:=n div 2;
    end;
  writeln(res);

  //fin;
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.

const
   fin='';fon='';
var
   n,i,d:int64;
procedure nhap;
   begin
   assign(input,fin);reset(input);
   assign(output,fon);rewrite(output);
   readln(n);
   end;
procedure xuli;
   begin
   d:=1;
   while n>1 do
      begin
      if n mod 2=1 then begin inc(d); n:=n-1; end
      else
      if n mod 2=0 then begin n:=n div 2; end;
      end;
   writeln(d);
   close(input);
   close(output);
   end;

begin
nhap;
xuli;
end.

Program Bakteriy;
Var x,k,i:longint;
Begin
readln(x);
k:=0;
while x>0 do
 begin
  k:=k+x mod 2;
  x:=x div 2;
 end;
writeln(k);
readln;
End.

Var x,k:integer;
Begin
    Read(x);
    Repeat Inc(k,x mod 2);
        x:=x div 2;
    Until x=0;
Write(k);
End.

var n,k,m,i,k1:longint;
    mas:array[1..30] of longint;

begin
 readln(n);k:=1;m:=1;
 m:=1;k:=1; i:=2;
 while k1<>5 do
  begin
   m:=m*2;
   if m>n then begin m:=m div 2;
                n:=n-m;
                m:=1;
                if n<>0 then k:=k+1;
               end;
   if (n=0)or(n=1) then k1:=5;
  end;
 write(k);

end.

var a:Extended;
l:Longint;
begin
l:=0;
readln(a);
 while a>0 do begin
  if round(a) mod 2 = 0 then a:=a/2
  else begin a:=a-1; l:=l+1; end;
 end;
 writeln(l);
end.

var n,k:longint;
begin
 readln(n);
 k:=0;
 while n>1 do
  begin
   while n mod 2=0 do
    n:=n div 2;
   if (n mod 2=1) and (n>1)
    then begin dec(n); inc(k); end;
  end;
 writeln(k+1);
end.

Program asd;
var x,n,k:integer;
begin
x:=1073741824;
readln(n);
repeat
if n>=x then begin k:=k+1; n:=n-x; end else x:=x div 2;
until n=0;
writeln(k);
end.

var
n,i,k:longint;
begin
k:=1;
readln(n);
while n>1 do begin
if n mod 2 <>0 then begin dec(n);inc(k);end;
n:=n div 2;
end;
write(k);
end.

var xx,n,res    :int64;
    i:longint;
    x:array[0..64]of int64;
begin
     read(xx);
     x[0]:=1;
     for i:=1 to 60 do x[i]:=x[i-1]*2;
     while xx<>0 do
        begin
           for i:=1 to 63 do
             if x[i]>xx then
                 begin
                      inc(res);
                      xx:=xx-x[i-1];
                      break;
                 end;
           end;
     write(res);
end.

uses math;
var
        mu, res, x: integer;

begin
        readln(x);

        while x <> 0 do
        begin
                if odd(x) then
                begin
                        inc(res);
                        dec(x);
                end;
                while (x mod 2 = 0) and (x <> 0) do x := x div 2;

        end;
        writeln(res);
end.

var
  a, b, c: int64;

begin
  readln(a);
  b := 0;
  while a > 0 do begin
    if a mod 2 = 0 then a := a div 2
      else begin
        dec(a);
        inc(b);
      end;
  end;
  writeln(b);
end.

var s,k,x:longint;

begin
   read(x);
   k:=1;
   s:=1;
   while s<>x do
    begin
     s:=1;
     while s<x do
      s:=s*2;
      if s=x then break
             else begin
                   inc(k);
                   if s+1=x then break;
                   s:=s div 2;
                   x:=x-s;
                  end;
     end;
   write(k);
end.

Var x,k:integer;Begin Read(x);Repeat Inc(k,x mod 2);x:=x div 2;Until x=0;Write(k);End.

program bugteria;
var x,w:longint;
begin
w:=1;
readln(x);
if x>1 then
repeat
if x>=2 then
w:=w+(x mod 2);
x:=x div 2
until x=1;
Writeln(w)
end.

var n,ans:longint;

begin
    readln(n);
    while n<>0 do begin
        inc(ans,n mod 2);
        n:=n div 2;
    end;
    write(ans);
end.

//CF

var
  n, res: longint;

begin
  //assign(input, 'CF579A.iNP'); reset(input);
  //assign(output, 'CF579A.oUT'); rewrite(output);
  readln(n);
  while n > 0 do
        begin
          inc(res, n mod 2);
          n:= n div 2;
        end;
  writeln(res);
  //close(input); close(output);
end.

var n,k:integer;
begin
read(n);
while n>0 do
begin
k:=k+(n mod 2);
n:=n div 2;
end;
write(k);
end.

var
  x,ans:integer;
begin
  readln(x);
  ans:=0;
  while x>0 do
    begin
      if x mod 2=1 then inc(ans);
      x:=x div 2;
    end;
  writeln(ans);
end.

var
  x,ans:int64;
begin
  readln(x);
  ans:=0;
  while x>0 do
    begin
      if x mod 2=1 then inc(ans);
      x:=x div 2;
    end;
  writeln(ans);
end.

var
k,n:longint;
begin
assign(input,'');reset(input);
assign(output,'');rewrite(output);
readln(n);
k:=1;
while n>1 do
      begin
      if n mod 2=0 then n:=n div 2
      else
         begin
         n:=n-1;
         k:=k+1;
         end;
      end;
writeln(k);
close(input);close(output);
end.

program z1;
var x,ans:longint;
begin
read(x);
ans:=1;
while x<>1 do begin
if x mod 2<>0 then begin dec(x);inc(ans);end;
x:=x div 2;
end;
write(ans);
end.

const
        fin='';
        fon='';
var
        d,i,n:longint;
begin
assign(input,fin);
reset(input);
assign(output,fon);
rewrite(output);
read(n);
while n<>0 do
        begin
        d:=d+n mod 2;
        n:=n div 2;
        end;
write(d);
end.

{$mode objfpc}
program RB;
var n,i,d,g:int64;
begin
   readln(n);
  i:=1;
  while i*2<=n do i:=i*2;
  repeat
     g:=n div i;
     if g=1 then inc(d);
     n:=n mod i;
     i:=i div 2;
  until i=0;
  writeln(d);
end.

var a,b:longint;
begin
readln(a);
while a <> 0 do
begin
if a mod 2 = 1 then inc(b); a:= a div 2; end;
write(b);
end.

const fi='';
      fo='';
var f:text;
    n,res:longint;

begin
  assign(f,fi);reset(f);
  readln(f,n);

  assign(f,fo);rewrite(f);
  while (n > 0) do
        begin
          if n mod 2 = 1 then inc(res);
          n:=n div 2;
        end;
  write(f,res);
  close(f);
end.

var a,k:int64;
begin
  readln (a);
  k:=0;
  while (a>0) do
   begin
     a:=a and (a-1);
     k:=k+1;
   end;
  writeln (k);
end.

var
 a,o,i,j,h,g,l,n,k:longint;
begin
 readln(n);
 while(n>0)do
 begin
  if(n mod 2=1)then inc(o);
  n:=n div 2;
 end;
 writeln(o);
end.

var k, ch:longint;
begin
  readln(ch);
  K := 1;
 while (ch<>1) do begin
  if ch mod 2 = 1 then begin
    ch := ch div 2;
    k:= K+1
  end else begin
    ch := ch div 2;
  end
end;
write(k);
end.

Var x,k:Longint;
Begin
    Readln(x);
    While x<>0 do begin
        k:=k + x mod 2;
        x:=x div 2;
    End;
    Writeln(k);
End.

var n,ans:int64;
begin
read(n); ans:=0;
while n>0 do
begin
if n mod 2<>0 then inc(ans);
n:=n div 2;
end;
write(ans);
end.

var
n,s:longint;
begin
readln(n);
s:=0;
while n>0 do
  begin
    if n mod 2=1 then inc(s);
    n:=n div 2;
  end;
writeln(s);
end.

var
 n,s:longint;
begin
 readln(n);
 while n>0 do
  begin
   if n mod 2=1 then inc(s);
   n:=n div 2;
  end;
 writeln(s);
end.

var x, ans:integer;

begin
  readln(x);
  ans := 0;
  while x > 0 do
  begin
    ans := ans + x mod 2;
    x := x div 2;
  end;
  writeln (ans);
end.

var
	n, b, x, y: int64;
	a: array of integer;

begin

	readln(n);
	while (n > 0) do
	begin
		if (n mod 2 <> 0) then
			x += 1;
		n := n div 2;
	end;

	writeln(x);

end.

var x, m : Integer;
begin
  Readln(x);
  While (x > 1) do If x mod 2 = 0 then x := x div 2
                                  else begin
                                         m := m + 1;
                                         x := x div 2;
                                       end;
  Writeln(m + 1);
end.

var
i,j,x:integer;
begin
read(x);
j:=0;
  while x>=1 do
    begin
      if x mod 2 <> 0 then
        j+=1;
      x:=x div 2;
    end;
write(j);
end.

                               {***ABDU***}
var x,i,n:int64; begin
readln(n);
while n>0 do begin
if n mod 2=1 then inc(i); n:=n div 2;end;
writeln(i);
end.

program zzz;
var
  x: longint;
  kol: byte;
begin
  read(x); kol := 0;
  while x > 0 do
  begin
    if x mod 2 <> 0 then inc(kol);
    x := x div 2;
  end;
  write(kol);
end.

var x, y : longint;
begin
  readln(x);
  while x <> 0 do begin if x mod 2 = 1 then inc(y); x := x div 2; end;
  write(y);
end.

var
  n,ans : longint;
begin
  readln(n);
  while (n > 0) do
  begin
    if (n mod 2 = 1) then
      inc(ans);
    n := n div 2;
  end;
  writeln(ans);
end.

var
  x,s,i:integer;
begin
  s:=0;
  readln(x);
  while x>0 do
  begin
    if x mod 2=1 then
      inc(s);
      x:=x div 2;
  end;
  writeln(s);
end.

var x,res,i:longint;
begin
  readln(x);
  while x>0 do
    begin
      inc(res,x mod 2);
      x:=x shr 1;
    end;
  writeln(res);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, s: integer;
begin
  readln(n);
  s:= 0;
  while n > 0 do
    begin
      if (odd(n)) then inc(s);
      n:= n div 2;
    end;
  writeln(s);
  readln;
  readln;
end.

var m,x:longint;
begin
  readln(x);
  while x<>0 do
  begin
    m:=m+x and 1;
    x:=x>>1;
  end;
  writeln(m)
end.

program k;
var x,i,t:longint;
begin
{assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output);}
read(x);
i:=0;
while x<>0 do begin
t:=1;
while 2*t<=x do
t:=t*2;
x:=x-t;
inc(i);
end;
write(i);
{close(output); }
end.

 const eps=1e-11; besk=200000000000000008;
    modul=1000000007;
   label 1,2,3,4,11;
    type
    mas=array [-10000..1000000] of int64; point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[-10000..10000000] of int64;mass1=^mass;
    var kol,pold,px,py,ll,aa,bb,cc,n1,n2,dist,pos,dloch,x0,x1,sum,tt,pp,t,v1,v2,p3,p4,t4,t5,t6,t1,t2,t3,jj,xx,yy,ost,rr,p,q,h,n,kk,qq,ot,nn,p1,p2,y0,s1,s2,m,s,imax,smin,dl,besk1:int64;
    ii,start,k,shag,imin,i1,i2,i3,i4,i5,i6,i7,j1,j2,mask,step,i,j:longint;
     sssnew:array[-10..1000] of char;
    poin:zap;
    vec:array[-100..1000] of zap;
     c1,c2:array[-1000..100000] of int64;
    xnew,x,y,z,och,newoch,fact,d, a1,bl,br,c,a,b:array[-2000000..2000000] of int64;
    ss,ss1,ss2,name1,name2 :string;
    newgr,gr:array[-100..2000] of boolean;
    slov:array[-1..1500,-1..500] of string;
    ssot:array[-100..10000] of char;
    ch: char;
   newzan, zan,marked:array[-1000..2000000] of boolean;
    sp,sss,maxpr:array[0..10000] of string;
   hh,ttt, l, pr,aanew,v0,s0,t0:extended;
   mmask:array[0..15,0..35000,0..15] of longint;
   { z,y,x:array[-1..300,-10..1000] of int64;
    } xxx,yyy:array[-1..1000] of double;
   tt1, xxnew,per,pp2, ee,yot:double;
       flagg,flag2,flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin repeat z:=x mod y;x:=y;y:=z; until z=0 ; nod:=x;end;

  function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;
  tt:zap; tt1:zap1;
begin
  if a<b then begin r:=a;a:=b;b:=r; end;
  x2:=1;x1:=0;y2:=0;y1:=1;
  while b>0 do
    begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;
          a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;
    end;
    d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;
   evkl:=tt1;
end;

function degg(a:int64;k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul else
   begin p:=degg(a,k div 2); degg:=(p*p) mod modul; end;

end;

begin

   {  assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
      read(pp); ot:=0;
      while pp>0 do
        begin
           ot:=ot+pp mod 2;
           pp:=pp div 2;

        end;
         writeln(ot);

1: close(output);

end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var x,k:longint;
a:int64;
begin
read(x);
k:=0;
while x<>0 do begin
  a:=1;
  while a<=x do a:=a*2;

 x:=x-(a div 2);
 inc(k);
end;
writeln(k);
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, s: integer;
begin
  readln(n);
  s:= 0;
  while n > 0 do
    begin
      if (odd(n)) then inc(s);
      n:= n div 2;
    end;
  writeln(s);
  readln;
  readln;
end.

{CF579A}
var
x,s:longint;
begin
read(x);
s:=0;
repeat
inc(s,x mod 2);
x:=x div 2;
until x=0;
writeln(s);
end.

var
 x,res:int64;
begin
 readln(x);
 repeat
  if x mod 2<>0 then inc(res);
  x:=x div 2;
 until x=0;
 writeln(res);
end.

var i,n:longint;
    begin
    read(n);
    i:=1;
    while i<=n do
          i:=i*2;
    i:=i div 2;
    write(n-i+1);
    end.

Program Bakteriy;
Function Step(a,b:integer):int64;
var i,p:longint;
begin
p:=1;
for i:=1 to b do
 p:=p*a;
step:=p;
end;
Var x,i,ans:longint;
Begin
readln(x);
i:=0;
while x>=step(2,i) do
 i:=i+1;
i:=i-1;
ans:=1+x-step(2,i);
writeln(ans);
readln;
End.

var x,a:longint;
Begin
readln(x);
a:=x mod 2;
if a=0 then writeln('1')
else writeln('2');
end.

var
        n:longint;

procedure enter;
begin
        readln(n);
end;

procedure process;
var
        i,j:longint;
begin
        if n=1 then
        begin
                writeln(1);
                exit;
        end;
        j:=1;
        for i:=1 to 30 do
        begin
                j:=j*2;
                if j=n then
                begin
                        writeln(1);
                        exit;
                end;
        end;
        writeln(2);
end;

Begin
        enter;
        process;
End.

var i,j,n,d:qword;
begin
readln(n);
i:=1;d:=0;
if n mod 2=0 then d:=1;
if n mod 2<>0 then d:=(n mod 2)+1;
writeln(d);
end.

const   fi      ='';
        fo      ='';
var     n,res   :longint;
procedure nhap;
begin
        assign(input,fi);
        reset(input);
                readln(n);
        close(input);
end;
procedure xuli;
begin
        repeat
                if odd(n) then  inc(res);
                n:=n div 2;
        until n>0;
end;
procedure xuat;
begin
        assign(output,fo);
        rewrite(output);
                writeln(res);
        close(output);
end;
begin
        nhap;
        xuli;
        xuat;
end.

Program Problem_A;
Const fi='';
      fo='';
      MaxN=1000000000;
Type ii= longint;
     li= int64;
Var N: ii;
    Min: ii;
Procedure Doc_Dl;
  Var f: text;
  Begin
    Assign(f,fi);
    Reset(f);
    Readln(f,N);
    Close(f);
  End;
Procedure Xu_Ly;
  Var tg: li;
  Begin
    tg:=1;
    While (N>tg) do
      tg:=tg*2;
    If Abs(tg-N)<Abs(tg div 2-N) then
      Min:=Abs(tg-N)
    Else Min:=Abs(tg div 2-N);
  End;
Procedure Ghi_Dl;
  Var f: text;
  Begin
    Assign(f,fo);
    Rewrite(f);
    If Min=0 then Min:=1;
    Writeln(f,Min);
    Close(f);
  End;
BEGIN
  Doc_Dl;
  Xu_ly;
  Ghi_Dl;
END.

var
 a,b:longint;
begin
 read(a);
 while a>0 do
 begin
  if a mod 2=0 then inc(b);
  a:=a div 2;
 end;
 writeln(b);
end.

var k,s,x:int64;

begin
 readln(x);
 k:=1;
 s:=1;
 while s<x do
  s:=s*2;
 if s<>x then begin
               s:=s div 2;
               k:=k+(x-s);
              end;
 writeln(k);
end.

program Ad;

{$APPTYPE CONSOLE}

uses
  SysUtils,Math;

var
   a,b:array[1..10] of integer;
   s,n :int64;
   i:integer;
begin
   readln(n);
   s:=1;
   //k:=1;
   for i:=1 to 33 do
   begin
      if(s=n) then
      begin
         writeln(1);
         break;
      end;
      if(s*2>n) then
      begin
         writeln(1+n-s);
         break;
      end;
      s:=s*2;
   end;
   readln;
   readln;
end.

const
   fin='';fon='';
var
   n,i,d:int64;
procedure nhap;
   begin
   assign(input,fin);reset(input);
   assign(output,fon);rewrite(output);
   readln(n);
   end;
function kt(x:longint):boolean;
   begin
   while (x mod 2)=0 do
      x:=x div 2;
   if x=1 then exit(true)
   else exit(false);
   end;
procedure xuli;
   begin
   if kt(n)=true then begin writeln(1); exit; end
   else
   begin
   d:=1;
   while kt(n)=false do
      begin
      if n mod 2=1 then begin inc(d); n:=n-1; end
      else
      if n mod 2=0 then begin inc(d); n:=n div 2; end;
      end;
   end;
   writeln(d);
   close(input);
   close(output);
   end;

   begin
nhap;
xuli;
end.

const fin='';fon='';
var x:qword;
begin
assign(input,fin);
reset(input);
assign(output,fon);
rewrite(output);
readln(x);
if x mod 2=0 then write('1')
else write('2');
close(input);close(output);
end.

program Ad;

{$APPTYPE CONSOLE}

uses
  SysUtils,Math;

var
   a,b:array[1..10] of integer;
   s,n :int64;
   i:integer;
begin
   readln(n);
   s:=1;
   for i:=1 to 33 do
   begin
      if(s=n) then
      begin
         writeln(1);
         break;
      end;
      if(s*2>n) then
      begin
         writeln(min(1+n-s,n));
         break;
      end;
      s:=s*2;
   end;
   readln;
   readln;
end.

var z,i:int64;
m:string;
begin
readln(z);
repeat
if z mod 2 = 0 then begin
m:='0'+m;
end
else M:='1'+m;
z:=z div 2;
until (z=1) or (z=0);
M:='1'+m;
z:=0;
for i:=1 to length(m) do begin
if m[i]='1' then z:=z+1;
end;
writeln(z);
end.

var x,a,k:longint;
Begin
k:=1;
readln(x);
while x>1 do
Begin
if x mod 2 =0 then Begin x:=x div 2 ;  end    else
if x mod 2 =1 then Begin x:=x-1; k:=k+1;if x=2 then k:=k+1; end;
end;
writeln(k);
end.

program Ad;

{$APPTYPE CONSOLE}

uses
  SysUtils,Math;

var
   a,b:array[1..10] of integer;
   s,n :int64;
   i:integer;
begin
   readln(n);
   s:=1;
   for i:=1 to 33 do
   begin
      if(s=n) then
      begin
         writeln(1);
         break;
      end;
      if(s*2>n) then
      begin
         writeln(1+n-s);
         break;
      end;
      s:=s*2;
   end;
   readln;
   readln;
end.

var i,n,d:qword;
begin
readln(n);
d:=0;
if n mod 2=0 then d:=1;
if n mod 2<>0 then d:=(n mod 2)+1;
writeln(d);
end.

var n,m,i,j,k,ans,l,r:Longint;
  begin
    read(n);
    l:=0;
    ans:=0;
    while (n>1) do
     begin
       if (n mod 2=0) and (l<>2) then begin inc(ans); l:=2; end;
       if n mod 2=0 then n:=n div 2 else begin inc(ans); l:=1; n:=n-1; end;
     end;
    writeln(ans);
  end.

var i, ch,z,st_10,k:longint;
s : string;
begin
  readln(ch);
  s:='';
  k:= 0;
  z:= 0;
  st_10:=1;
  while ch<>0 do
  begin
   z:=z+(ch mod 2)*st_10;
   ch:=ch div 2;
   st_10:=st_10*10;
  end;
  str(z,s);
  for i := 1 to Length(s) do
    if s[i] = '1' then k := 1 + k;
    write(k);
end.

var
x,o,d,t,k:longint;
begin
read(x);
o:=1;
t:=1;
d:=x;
k:=0;
while x-o*2>=0 do
o:=o*2;
x:=x-o;
if x=0
then
write(t)
else
begin
if d mod 2=0
then
while d mod 2=0 do
d:=d div 2
else
begin
while d>0 do
begin
if d mod 2=1
then
begin
d:=d-1;
k:=k+1;
end;
if d mod 2=0
then
d:=d div 2;
end;
d:=d+k;
end;
if x+1>=d
then
write(d)
else
write(x+1);
end;
end.

var i,j,n,d,s:qword;
begin
{assign(input,'a.inp');reset(input);
assign(output,'a.out');rewrite(output);}
readln(n);
i:=1;d:=0;
s:=1;
while s<n do
        begin
        s:=s*2;
        inc(d);
        end;
if s=n then d:=1;
if s>n then
        begin
        s:=s div 2;
        d:=(n mod s)+1;
        end;
writeln(d);
{close(input);close(output);}
end.

{$mode objfpc}
var n,p:int64;
begin
  Readln(n);
  p:=1;
  while p*2<n do p*=2;
  Writeln(1+n-p)
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils, Math;

var
  n, i, s : integer;
begin
  readln(n);
  i:=1;
  while i*2<=n do
    i:=i*2;
  s:=1+(n mod i);
  writeln(s);
  readln;
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
x:integer;

 begin
 readln(x);
 IF x mod 2=0 then writeln(1) else if (x mod 2<>0) and (x<>1) then writeln(2)
 else if x=1 then writeln(2);
readln;
readln;
end.

var i,n:longint;
    begin
    read(n);
    i:=1;
    while i<=n do
          i:=i*2;
    i:=i div 2;
    write(n-i+1);
    end.

{$mode objfpc}
uses math;
var
        mu, res, x: integer;

begin
        readln(x);
        {
        while x div 2 <> 1 do
        begin
                if odd(x) then
                        begin
                                inc(res);
                                dec(x);
                        end
                else x := x div 2;
        end;
        writeln(res+1); }
        mu := 1;
        while power(2, mu) <= x do inc(mu);
        writeln(trunc(x - power(2, mu-1))+1);
end.

program bugteria;
var x,w:longint;
begin
w:=1;
readln(x);
repeat
if x>=2 then
w:=w+ x mod 2;
x:=x div 2
until x>0;
Writeln(w)
end.

var n,d,t: longint;
begin
assign(input,''); reset(input);
assign(output,''); rewrite(output);
readln(n);
d:=1;
t:=1;
while t< n do
        begin
        t:=t*2;
        end;
if t > n then t:=t div 2;
inc(d,n-t);
writeln(d);
close(input);
close(output);
end.

{$mode objfpc}
program RB;
var n:integer;
begin
   readln(n);
   if n mod 2=0 then write('1')
   else write(n div 2);
end.

var N : longint;
begin
     readln(n);
     if n = 1 then writeln(1) else
     if n mod 2 =0 then writeln(1) else writeln(2);
end.

const
   fin='';fon='';
var
   n,i,d:int64;
procedure nhap;
   begin
   assign(input,fin);reset(input);
   assign(output,fon);rewrite(output);
   readln(n);
   end;
function kt(x:longint):boolean;
   begin
   while (x mod 2)=0 do
      x:=x div 2;
   if x=1 then exit(true)
   else exit(false);
   end;
procedure xuli;
   begin
   if kt(n)=true then begin writeln(1); exit; end
   else
   begin
   i:=1;
   d:=1;
   while i<=n div 2 do
      i:=i*2;
   d:=d+n-i;
   end;
   writeln(d);
   close(input);
   close(output);
   end;
begin
nhap;
xuli;
end.

var x,res,i:longint;
begin
  readln(x);
  i:=1;
  while i<=x do  i:=i shl 1;
  res:=x-(i shr 1);
  writeln(res+1);
end.

{$mode objfpc}
var
        t,n,i:int64;
begin
        readln(n);
        t:=1;
        while t*2<=n do
                begin
                        t:=t*2;
                        inc(i);
                end;
        if t=n then
        writeln('1')
                else writeln(i-1+n-t);
end.

var n:longint;
inp,outp:text;
procedure nhap;
begin
assign(inp,'');
assign(outp,'');
reset(inp);
rewrite(outp);
read(inp,n);
end;

procedure tim;
var i,a,b,dem:longint;
begin
i:=1;  a:=0; dem:=1;
while i<n do
   begin
   i:=i shl 1;
   if i<n then a:=i;
   end;
if i=n then write(1) else
 begin
 b:=n-a;
  while b>2 do
            begin
             inc(dem);
             b:= b shr 1;
             end;

  write(dem+1);
 end;

end;
begin
nhap;
tim;
close(inp);close(outp);
readln
end.

var n,k,m:longint;

begin
 readln(n);k:=1;m:=1;
 while n<>m do
  begin
   if m*2>n then begin m:=m+1;k:=k+1 end
             else m:=m*2;
  end;
 write(k);
end.

                                        {***ABDU***}
var r1,r2,r3,r,a1,a2,i,j,n,m,a3,b3,suma,sumb,c:int64; a,b:array [1..10000] of int64;  begin
read(n);
if n mod 2=0 then writeln(1)
else begin
writeln(int(sqrt(n)));
end;
end.

var n,k,m,i,k1:longint;
    mas:array[1..30] of longint;

begin
 readln(n);k:=1;m:=1;
 for i:=1 to 30 do
  begin
   mas[i]:=m;
   m:=m*2;
  end;m:=1;k:=1; i:=1;
 while k1<>5 do
  begin
   if mas[i]=n then begin k1:=5;m:=mas[i]; end;
   if mas[i]>n then begin m:=mas[i-1];k1:=5 end;
   i:=i+1;
  end;
 if n-m<>0 then begin
 if (n-m)mod 2=0 then k:=k+1
                 else begin
                      if n-m=1 then k:=k+1
                               else k:=k+n-m-1;
                      end;
                end;
 write(k);
end.

program Ad;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
   a,b:array[1..10] of integer;
   i,s,n :integer;
begin
   readln(n);
   if(n mod 2=0) or (n=1) then writeln(1) else
   writeln(2);
   readln;
   readln;
end.

var i,j,n,d:qword;
begin
readln(n);
i:=1;d:=0;
if n mod 2=0 then d:=1;
if n mod 2<>0 then d:=(n mod 2)+1;
writeln(d);
end.

var n,i,dem :int64;
BEGIN
    read(n); i:=1;  dem:=0;
    if (n=1) or (n=2) or (n=4) or (n mod 8=0) then dem:=1 else
             while i<= n do
               begin
                    i:=i*2+1;
                    inc(dem);
               end;
               write(dem);
END.

var a,s,k,i,min,imin:longint;
begin
readln(a);
s:=1;
for i:=1 to round(sqrt(a)) do
begin
s:=i;
while true do
begin
if s*2>a then begin k:=a-s; break; end
else
s:=s*2;
end;
if (i=1) or (k < min) then begin min:=k; imin:=i; end;
end;
writeln(min+imin);
end.

var s,k,x:longint;

begin
   read(x);
   k:=1;
   s:=1;
   while s<=x do
    s:=s*2;

   if s<>x then begin
                 s:=s div 2;
                 k:=(x-s)+k;
                end;
   write(k);
end.

program z1;
var  x,d:longint;
begin
read (x);
d:=1;
while (x>d) do
        d:=d*2;
if (d>x) then d:=d div 2;
if (x=d) then writeln (1)
else
        writeln (1+x-d);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 n:integer;

begin
  readln(n);
  if (n mod 2 = 0 ) then writeln(1) else writeln(2);

end.

var N : longint;
begin
     readln(n);
     if n mod 2 =0 then writeln(1) else writeln(2);
end.

program Ad;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
   a,b:array[1..10] of integer;
   i,s,n :integer;
begin
   readln(n);
   if(n mod 2=0) then writeln(1) else
   writeln(2);
   readln;
   readln;
end.

var n,k,m,i,k1:longint;
    mas:array[1..30] of longint;

begin
 readln(n);k:=1;m:=1;
 for i:=1 to 30 do
  begin
   mas[i]:=m;
   m:=m*2;
  end;m:=1;k:=1; i:=1;
 while k1<>5 do
  begin
   if mas[i]=n then begin k1:=5;m:=mas[i]; end;
   if mas[i]>n then begin m:=mas[i-1];k1:=5 end;
   i:=i+1;
  end;
 if n-m<>0 then begin
 if (n-m)mod 2=0 then k:=k+1
                 else begin
                      if n-m=1 then k:=k+1
                               else k:=k+n-m;
                      end;
                end;
 write(k);
end.

var
i,j,x:integer;
begin
read(x);
i:=0;
  while x>=1 do
    begin
      if x mod 2 <> 0 then
        j+=1;
      x:=x div 2;
    end;
write(x);
end.

var
 n:longint;
begin
 readln(n);
 if odd(n) then writeln('0')
           else writeln('1');
end.

var x,i:int64;
begin
 readln(x); i:=1;
 if i = x then begin write('0'); exit; end;
 while i < x do
  i:=i * 2;
 if i = x then begin write('1'); exit; end;
 write('2');
end.

program battle4;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
n,s,i:integer;

begin
readln(n);
s:=1;
for i:=1 to n do begin
 s:=s*2;
 if s*2>n then break;
 end;
 s:=n-s+1;
 writeln(s);
readln;
end.

var  ch,z,st_10,k:int64;
i:integer;
s : string;
begin
  readln(ch);
  s:='';
  k:= 0;
  z:= 0;
  st_10:=1;
  while ch<>0 do
  begin
   z:=z+(ch mod 2)*st_10;
   ch:=ch div 2;
   st_10:=st_10*10;
  end;
  str(z,s);
  for i := 1 to Length(s) do
    if s[i] = '1' then k := 1 + k;
    write(k);
end.

var a,x:integer;
begin
read(x);
If x mod 2 =0 Then a:=1
              Else a:=2;
write(a);
end.

var i,n:longint;
    begin
    read(n);
    i:=1;
    while i<=n do
          i:=i*2;
    i:=i div 2;
    write(n-i+1);
    end.

var
 a,b:longint;
begin
 read(a);
 while a>0 do
 begin
  if a mod 2=0 then inc(b);
  a:=a div 2;
 end;
 writeln(b);
end.

var n :int64;
BEGIN
    read(n);
    if n mod 2=1 then write('2') else write('1');
END.

var n,i,dem :int64;
BEGIN
    read(n); i:=1;dem:=0;
    if (n div 2) mod 2<>0 then
    while i<= n do
    begin
     i:=(i*2);
       if i<=n then
          Begin
               inc(i);
               inc(dem);
          End;
    end;
    if (n div 2) mod 2<>0 then write(dem+1);
    if (n div 2) mod 2=0 then write('1');
END.

var a:integer;
begin
read(a);
if (a mod 2=0)then a:=1 else a:=2;
write(a);
end.

program Ad;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
   a,b:array[1..10] of integer;
   i,s,n :integer;
begin
   readln(n);
   if(n mod 2=0) or (n=1) then writeln(1) else
   writeln(2);
   readln;
   readln;
end.

{$mode objfpc}
var n,p:int64;
begin
  Readln(n);
  p:=1;
  while p*2<n do p*=2;
  Writeln(1+n-p)
end.

var
        t,n,s:int64;
function kt(x:int64):int64;
var
        g:int64;
begin
        g:=1;
        while g*2<=x do
                g:=g*2;
        kt:=x-g;
end;
begin
        readln(n);
        t:=kt(n);
        while t<>0 do
                begin
                        if t mod 2<>0 then inc(s);
                        t:=kt(t);
                end;
        writeln(t+1);

end.

var
x:longint;
begin
read(x);
if (x mod 2=0) or (x=1)
then
write('1')
else
write('2');
end.

var n,i,dem,t,dem2 :int64;
BEGIN
    read(n); i:=1;  dem2:=0;  t:=n;
     while 0<>n do
      begin
        while t mod 2=0 do t:=t div 2;
           if t=1 then dem:=1;
        n:= n div 2;

        if n mod 2=1 then begin dec(n); inc(dem2); end;
      end;
     if t=1 then write(dem) else write(dem2);
END.

var x,a:longint;
Begin
readln(x);
a:=x mod 2;
if a=0 then writeln('1')
else writeln('2');
end.

var n,k,m:longint;

begin
 readln(n);k:=1;m:=1;
 while n<>m do
  begin
   if m*2>n then begin m:=m+1;k:=k+1 end
             else m:=m*2;
  end;
 write(k);
end.

var n,m:longint;
inp,outp:text;
procedure nhap;
begin
assign(inp,'');
assign(outp,'');
reset(inp);
rewrite(outp);
read(inp,n);
end;
function lam(n:longint):longint;
var i:longint;
begin
i:=1;
while i<n do
   begin
   i:=i shl 1;
   if i<=n then m:=i;
   end;
end;

procedure tim;
var i,dem:longint;
begin
dem:=0;
while n>2 do
   begin
   inc(dem);
   lam(n);
   n:=n-m;
   end;
write(dem+n);
end;
begin
nhap;
tim;
close(inp);close(outp);
end.

program battle;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
n:integer;

begin
readln(n);
if n mod 2 = 0 then writeln(2) else writeln(1);
readln;
end.

var x,res,i:longint;
begin
  readln(x);
  i:=1;
  while i<=x do  i:=i shl 1;
  res:=x-(i shr 1);
  writeln(res+1);
end.

                                        {***ABDU***}
var r1,r2,r3,r,a1,a2,i,j,n,m,a3,b3,suma,sumb,c:int64; a,b:array [1..10000] of int64;  begin
read(n);
if n mod 2=0 then writeln(1)
else begin
writeln(int(sqrt(n)));
end;
end.

uses math;
function Bakt(n:longint):longint;
var i:longint;
    begin
    while n mod 2=0 do
          n:=n div 2;
    i:=1;
    while i<=n do
          i:=i*2;
    i:=i div 2;
    Bakt:=n-i+1;
    end;
var i,n:longint;
    b:boolean;
    begin
    read(n);
    if (n mod 2=1) and (n<>1) then b:=true;
    if b then
       write(min(Bakt(n),Bakt(n-1)+1))
       else
       write(Bakt(n));
    end.