You are given an integer number $$$n$$$. The following algorithm is applied to it:  if $$$n = 0$$$, then end algorithm;  find the smallest prime divisor $$$d$$$ of $$$n$$$;  subtract $$$d$$$ from $$$n$$$ and go to step $$$1$$$. Determine the number of subtrations the algorithm will make.

The only line contains a single integer $$$n$$$ ($$$2 \le n \le 10^{10}$$$).

Print a single integer — the number of subtractions the algorithm will make.

NoteIn the first example $$$5$$$ is the smallest prime divisor, thus it gets subtracted right away to make a $$$0$$$.In the second example $$$2$$$ is the smallest prime divisor at both steps.

program b1076;
var n,d,i,s,j:int64;
begin
read(n);
while n<>0 do begin
j:=2;
while((n mod j)<>0) do if j<=(trunc(sqrt(n))) then inc(j) else j:=n;;
n:=n-j;
inc(s);
 break;
 end;
 s:=s+n div 2;
 write(s);
end.

program xxx;
var n:int64;
d,c:int64;
begin
read(n);

if n>0 then

 while n>1 do
  begin
  d:=2;

  while (n mod d <> 0)and(d<sqrt(n)+1) do
  inc(d);

  if n mod d <> 0 then
  begin writeln('1');exit;end
  else

  if d mod 2 = 0 then
   begin
    c:=n div 2;
    n:=0;
   end
     else

   begin

    n:=n-d;
    c:=n div 2;
    inc(c);
    n:=0;
      end;
  end;

writeln(c);

end.

Program ILoveYou;
VAR n,i:int64;

function Prim(x : int64) : boolean;
VAR i:int64;
Begin
Prim:=true;
i:=2;
if (x < 2) then Prim:=false;
while (i <= sqrt(x)) do
Begin
if ((x mod i) = 0) then Begin Prim:=false; i:=x; end;
i:=i + 1;
end;

end;

Begin

Readln(n);
if (Prim(n)) then Writeln(1) else
Begin

i:=2;
while ((n mod i) <> 0) do
Begin
i:=i + 1;
end;

Writeln(1 + (n - i) div 2);

end;

Readln;
END.

var i,n:int64;
begin
  readln(n);
  if n mod 2=0 then writeln(n div 2)
   else begin
   	for i:=3 to 100000 do
   	  if n mod i=0 then break;
   	  if i=100000 then i:=n;
   	  writeln((n-i)div 2+1);
   end;
end.

Program p;
var n, i: int64;

begin
read(n);
if n mod 2 =0 then writeln(n div 2)
  else
  begin
    for var g:=3 to 100000 do
      if n mod g =0 then
        begin
        i:=g;
        break
        end;
  if i=0 then i:=n;
  writeln((n-i) div 2+1)
  end
end.

                  const eps=0.0000000001;  besk1=200000008;  nnn=4600000;
              modul={1000000007}998244353 ;
   besk=4000000000000000000;
   label 22,1,2,3,4;
    type    real=extended;   double=extended;
    mas=array [-300000..nnn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[-10000..nnn] of longint;mass1=^mass;
    var posleft,posright,n,xxx,yyy,dx,dy,m,w,h,zz,jjj,l,r,aa,bb,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,sq,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,rr,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;
   k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;
   d,xx,yy,b,a,zsum,y,x,z:array[-200000..4350012] of int64;
    prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;
    iii,oldpos,finot,vv,znak:int64;
    aold:mas;
    v,ans,ccc,dist,alpha,phi:extended;
    koef,polex,poley,dd:array[-1..2400,-1..2103] of int64;
    ppos,mma,ma:array[-1000..2000005,-1..15] of int64;
    xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;
    del:array[-1..100001,-1..150] of longint;
    z0,num,y1,z1,z2,kolnul,fact,next,prev,str,s,name,dnew, voltay,c,day:mas;
    zzz:array[0..125000000] of byte;
    aaa,bbb,x1,x2:extended;
    pole:array[-10..2002,-10..2005] of char;
    ddd,ppole,ddl,ddr,dd3,dd4:array[-10..200,-10..220] of int64;
    ddnew:array[-1..12,-1..12,0..200,0..3] of int64;
   newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;
    ssold,sss1,sss2:string;
    def,stepen,koled,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;
     zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;
    ss1,ss2,ss:string;ch,ch1,ch2:char;
    pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;
    s3,s2,s1:array[-100..500000] of string;

    grr :array [-10..2010,-10..2010] of boolean;
    maxpr:array[0..nnn] of string;
    sss:array[-10..nnn] of string;
     tx,ty,vel,ott,v0,v1,s0,t0:int64;
     zv:point;
     left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;
     mash,sqx,sqy,ottt:extended;
     xxxx,yyyy,yot:double;
       flag2,flag,flag1:boolean;

  function max(a,b:int64):int64;
begin max:=a; if b>a then max:=b;   end;

  function min(a,b:int64):int64;
begin min:=a; if b<a then min:=b;   end;

procedure udal(p:longint);
begin  next[prev[p]]:=next[p]; prev[next[p]]:=prev[p]; 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 summ(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=t1 div tt mod modul;
    t2:=t2 div tt mod modul;
    ott.p1:=t1; ott.p2:=t2;

   summ:=@ott;
 end;

     function prod(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=(t1 div tt) mod modul;
    t2:=(t2 div tt) mod modul;
    ott.p1:=t1; ott.p2:=t2;

   prod:=@ott;
 end;

    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{/pi*180};
 end;

function degg(a,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 shr 1); degg:=p*p mod modul;   end;

end;

function prost(tt:int64):boolean;
var aa:extended; i,p,t:longint;  fl:boolean;
 begin
   fl:=true;
   aa:=tt;
   aa:=sqrt(aa);
   t:=round(aa);
   for i:=2 to t do if tt mod i=0 then fl:=false;

   prost:=fl;
 end;

function arcsin(pp:extended):extended;
var tt:extended;
begin
   if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)
   then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;
   tt:=1-pp*pp;
   if abs(tt)>=0 then
     begin
        arcsin:=arctan(pp/sqrt(tt));

     end;

end;

function gl(ch:char):boolean;
begin
 if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;

end;

function zaprmax(left,right:longint):int64;
begin
   if left>=right then zaprmax:=y[left] else
     begin
        if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else
         begin
          if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);
          if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);

         end;

     end;

end;

 function ff(gr:int64):boolean;

var ot,aa,bb,cc:int64; fl:boolean;
begin
  aa:=1; bb:=m;  cc:=aa; fl:=false;
  while abs(aa-bb)>1 do
    begin
       cc:=(aa+bb) shr 1;
       if y[cc]<gr then aa:=cc else bb:=cc;

    end;
  { writeln(' cc= ',cc);
  } cc:=min(cc+3,m+1);
   repeat dec(cc) until y[cc]<=gr;
   if y[cc]=gr then fl:=true else fl:=false;
  ff:=fl;
end;

function minprdel(t:int64):int64; label 2;
var i,j:longint; ot,p,pp:int64; v:extended; fl:boolean;
begin
  v:=t;
  v:=sqrt(v)+eps;
  fl:=false;
  for i:=2 to trunc(v) do if t mod i=0 then begin pp:=i; fl:=true; goto 2; end;
2: if fl then minprdel:=pp else minprdel:=t;

end;

begin
   { assign (input,'D:\Projects\input.txt');reset(input);
      assign (output,'D:\Projects\output.txt'); rewrite(output);
    }

      readln(t);
                  ot:=0;
    while t>0 do
      begin
         p:=minprdel(t);
         if p=2 then begin ot:=ot+t div 2; t:=0;  end else
           begin  inc(ot); t:=t-p;   end;
       {  writeln(t,' ',ot);
        }
      end;

        writeln(ot);

1:             close(output);
end.

var
  i,n,l:int64;

function _KTNT(x:qword):boolean;
  var
    i:longint;
  begin
    if x<=1 then exit(false);
    for i:=2 to trunc(sqrt(x)) do
      if (x mod i = 0) then exit(false);
    exit(true);
  end;

BEGIN
//  assign(input,'A.inp'); reset(input);
//  assign(output,'A.out'); rewrite(output);

  read(n);

  if (n mod 2 = 0) then
    begin
      write(n div 2);
      halt;
    end;

  i:=1;
  while (i <= trunc(sqrt(n))) do
    begin
      if (n mod i = 0) then
        begin
          if (_KTNT(i) = true) then begin l:=i; break; end else
          if (_KTNT(n div i) = true) then
            begin
              l:=n div i;
              break;
            end;
        end;
      inc(i);
    end;

  write((n - l) div 2 + 1);
//  close(input);
//  close(output);
END.

var
  i,n,l:int64;

function _KTNT(x:int64):boolean;
  var
    i:longint;
  begin
    if (x = 1) then exit(false);
    for i:=2 to trunc(sqrt(x)) do
      if (x mod i = 0) then exit(false);

    exit(true);
  end;

BEGIN
  //assign(input,'A.inp'); reset(input);
  //assign(output,'A.out'); rewrite(output);

  read(n);

  if (n mod 2 = 0) then
    begin
      write(n div 2);
      halt;
    end;

  i:=1;
  while (i <= trunc(sqrt(n))) do
    begin
      if (n mod i = 0) then
        begin
          if (_KTNT(i) = true) then
            begin
              l:=i;
              break;
            end;
          if (_KTNT(n div i) = true) then
            begin
              l:=n div i;
              break;
            end;
        end;

      inc(i);
    end;

  write((n - l) div 2 + 1);

  //close(input);
  //close(output);
END.

var f : text;
i,dem,j: longint;
n,kq : int64;
function kt(i : int64) : boolean;
begin
        kt := true;
        for j := 2 to trunc(Sqrt(i)) do
                if i mod j = 0 then
                        begin
                                kt := false;
                                break;
                        end;
end;
begin
        readln(n);
        dem := 1;
        kq := 0;
        if n>1 then
        begin
        if n mod 2 <> 0 then
                begin
        for i := 3 to trunc(sqrt(n)) do
                if (n mod i = 0)and(kt(i)=true) then
                        begin
                                kq := ((n div i)-1)*i;
                                kq := kq div 2 + 1;
                                break;
                        end;
                end else kq := n div 2;
        if kq=0 then kq := 1; {}
        end;
        writeln(kq);
end.

var n,s:int64;i:longint;
f:boolean;
begin
//assign(input,'csjf.in');reset(input);
//assign(output,'csjf.out');rewrite(output);
readln(n);
for i:=2 to trunc(sqrt(n)) do
  if n mod i=0 then
    begin
    f:=true;break;
    end;
if f=false then
  writeln(1)
else
  begin
while n mod 2<>0 do
  begin
  s:=s+1;
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then
      break;
  n:=n-i;
  end;
writeln(s+n div 2);
  end;
close(input);close(output);
end.

var n,t:int64;
i:longint;
begin
//assign(input,'csjf.in');reset(input);
//assign(output,'csjf.out');rewrite(output);
readln(n);
if n mod 2=0 then writeln(n div 2)
else
  begin
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then
      begin
      t:=i;break;
      end;
  if t=0 then t:=n;
  writeln((n-t) div 2+1);
  end;
close(input);close(output);
end.

var
bol:boolean;
n,ind:int64;
i,j:longint;
begin
readln(N);
for i:=2 to round(sqrt(n)) do begin
    if n mod i =0 then begin
    bol:=false;

        if bol=false then begin
            ind:=i;
            break;
        end;
    end;
    if ind<>0 then break;
end;

if ind=0 then writeln(1)
else  begin
if ind=2 then writeln(n div ind)
else begin
    writeln(1+(n-ind) div 2);
end;
end;
end.

var n, d, m : int64;

begin
    readln(n);
    if (n mod 2 = 0) then writeln(n div 2)
    else
    begin
        d := 3; m := n;
        while (d * d <= n) do
        begin
            if (n mod d = 0) then
            begin
                m := n div d;
                break;
            end;
            d := d + 2;
        end;
        if (m = n) then d := n;
        writeln((n - d) div 2 + 1);
    end;
end.

var n,count:int64;
    i:longint;
function check(n:int64):boolean;
var i:longint;
begin
    if n=3 then exit(true);
    i:=3;
    while i<=trunc(sqrt(n)) do
       if (n mod i)=0 then exit(false)
       else i:=i+2;
    exit(true);
end;
begin
    readln(n);
    count:=0;
    if (n mod 2)=0 then
        begin count:=count + n div 2; write(count); halt; end
    else
        if check(n) then begin inc(count); write(1); halt; end
        else
             begin
                i:=3;
                while i<=trunc(sqrt(n)) do
                   if (n mod i=0)and(check(i)) then
                      begin
                         inc(count);
                         count:=count+(n-i)div 2;
                         write(count);
                         halt;
                      end
                   else i:=i+2;
             end;
end.

var n,dem:int64;
    i:longint;
function check(n:int64):boolean;
var i:longint;
begin
    if n=3 then exit(true);
    i:=3;
    while i<=trunc(sqrt(n)) do if (n mod i)=0 then exit(false)
       else i:=i+2;
    exit(true);
end;
begin
    readln(n);
    dem:=0;
    if (n mod 2)=0 then
        begin dem:=dem + n div 2; write(dem); end
    else
        if check(n) then begin inc(dem); write(1); end
        else
             begin
                i:=3;
                while i<=trunc(sqrt(n)) do
                   if (n mod i=0)and(check(i)) then
                      begin
                         inc(dem);
                         dem:=dem+(n-i)div 2;
                         write(dem);
                         halt;
                      end
                   else i:=i+2;
             end;
end.

program task_2;

uses
  Classes, SysUtils, Math;

var
  L: string;
  N: Int64;
  C: Int64;
  I: Int64;
  M: Int64;

begin
  Readln(L);
  N := StrToInt64(L);
  C := 0;
  while N > 0 do
  begin
    if N > 1 then
    begin
      if N div 2 = N / 2 then
      begin
        Inc(C, N div 2);
        N := 0;
      end
      else
      begin
        M := Trunc(Sqrt(N));
        I := 2;
        while (N mod I <> 0) and (I < M) do
          Inc(I);
        if N mod I <> 0 then
          I := N;
        Inc(C);
        N := N - I;
      end;
    end
    else
    begin
      Inc(C);
      N := 0;
    end;
  end;
  Writeln(C);
end.

var d,n:int64;
    i:longint;
begin
  read(n);
  if (n=2)or(n=3)then d:=n
  else
  begin
    d:=0;
    for i:=2 to round(sqrt(n))+1 do
      if n mod i = 0 then
      begin
        d:=i;
        break;
      end;
    if d = 0 then d:=n;
  end;
  if d = 0 then d:=n;
  if d=2 then writeln(round(n/2))
  else writeln(1+round((n-d)/2));
end.

var n,d,i,s,j:int64;
begin
read(n);
while n<>0 do begin
j:=2;
while((n mod j)<>0) do if j<=(trunc(sqrt(n))) then inc(j) else j:=n;;
n:=n-j;
inc(s);
exit;
end;
s:=s+n div 2;
write(s);
end.

var n,d,i,s,j:int64;

begin
read(n);
while n<>0 do begin
 j:=2;
  while((n mod j)<>0) do if j<=(trunc(sqrt(j))) then inc(j) else j:=n;;
 n:=n-j;
 inc(s);
 break;
 end;
 s:=s+n div 2;
 write(s);
end.

var n,d,i,s,j:int64;

begin
read(n);
while n<>0 do begin
 j:=2;
  while((n mod j)<>0) do if j<trunc(sqrt(j)) then inc(j) else j:=n;;
 n:=n-j;
 inc(s);
 break;
 end;
 s:=s+n div 2;
 write(s);
end.

var n,d,i,s,j:int64;

begin
read(n);
while n<>0 do begin
 j:=2;
  while((n mod j)>0)and(j<=n)do inc(j);
  break;
 end;
 write(n div j);
end.

program xxx;
var n:int64;
d,c:int64;
begin
read(n);

d:=2;

if n>0 then

 while n>1 do
  begin

  while n mod d <> 0 do
  inc(d);

  c:=c+n div d;
  n:=n-((n div d) * d);

  end;

writeln(c);

end.

program xxx;
var n:int64;
d,c:int64;
begin
read(n);

if n>0 then

 while n>1 do
  begin
  d:=2;

  while (n mod d <> 0)and(d<sqrt(n)+1) do
  inc(d);

  if d mod 2 = 0 then
   begin
    c:=n div 2;
    n:=0;
   end
     else

   begin

    n:=n-d;
    c:=n div 2;
    inc(c);
    n:=0;
      end;
  end;

writeln(c);

end.

Program ILoveYou;
VAR n,i:int64;

function Prim(x : int64) : boolean;
VAR i:int64;
Begin
Prim:=true;
i:=2;
if (x < 2) then Prim:=false;
while (i <= sqrt(x)) do
Begin
if ((x mod i) = 0) then Begin Prim:=false; i:=x; end;
i:=i + 1;
end;

end;

Begin

Readln(n);
if (Prim(n)) then Writeln(1) else
Begin

i:=2;
while ((n mod i) <> 0) do
Begin
i:=i + 1;
end;

Writeln(n div i);

end;

Readln;
END.

Program p;
var n, i: int64;

begin
read(n);
if n mod 2 =0 then writeln(n div 2)
  else
  begin
    for var g:=3 to 10000 do
      if n mod g =0 then
        begin
        i:=g;
        break
        end;
  if i=0 then i:=n;
  writeln((n-i) div 2+1)
  end
end.

                  const eps=0.0000000001;  besk1=200000008;  nnn=4600000;
              modul={1000000007}998244353 ;
   besk=4000000000000000000;
   label 22,1,2,3,4;
    type    real=extended;   double=extended;
    mas=array [-300000..nnn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[-10000..nnn] of longint;mass1=^mass;
    var posleft,posright,n,xxx,yyy,dx,dy,m,w,h,zz,jjj,l,r,aa,bb,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,kol,sq,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,rr,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,smin,cen:int64;
   k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;
   d,xx,yy,b,a,zsum,y,x,z:array[-200000..4350012] of int64;
    prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;
    iii,oldpos,finot,vv,znak:int64;
    aold:mas;
    v,ans,ccc,dist,alpha,phi:extended;
    koef,polex,poley,dd:array[-1..2400,-1..2103] of int64;
    ppos,mma,ma:array[-1000..2000005,-1..15] of int64;
    xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;
    del:array[-1..100001,-1..150] of longint;
    z0,num,y1,z1,z2,kolnul,fact,next,prev,str,s,name,dnew, voltay,c,day:mas;
    zzz:array[0..125000000] of byte;
    aaa,bbb,x1,x2:extended;
    pole:array[-10..2002,-10..2005] of char;
    ddd,ppole,ddl,ddr,dd3,dd4:array[-10..200,-10..220] of int64;
    ddnew:array[-1..12,-1..12,0..200,0..3] of int64;
   newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;
    ssold,sss1,sss2:string;
    def,stepen,koled,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;
     zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;
    ss1,ss2,ss:string;ch,ch1,ch2:char;
    pr,hesh,numright,dr: array [-10..206000,-1..16] of int64;
    s3,s2,s1:array[-100..500000] of string;

    grr :array [-10..2010,-10..2010] of boolean;
    maxpr:array[0..nnn] of string;
    sss:array[-10..nnn] of string;
     tx,ty,vel,ott,v0,v1,s0,t0:int64;
     zv:point;
     left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;
     mash,sqx,sqy,ottt:extended;
     xxxx,yyyy,yot:double;
       flag2,flag,flag1:boolean;

  function max(a,b:int64):int64;
begin max:=a; if b>a then max:=b;   end;

  function min(a,b:int64):int64;
begin min:=a; if b<a then min:=b;   end;

procedure udal(p:longint);
begin  next[prev[p]]:=next[p]; prev[next[p]]:=prev[p]; 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 summ(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=t1 div tt mod modul;
    t2:=t2 div tt mod modul;
    ott.p1:=t1; ott.p2:=t2;

   summ:=@ott;
 end;

     function prod(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=(t1 div tt) mod modul;
    t2:=(t2 div tt) mod modul;
    ott.p1:=t1; ott.p2:=t2;

   prod:=@ott;
 end;

    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{/pi*180};
 end;

function degg(a,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 shr 1); degg:=p*p mod modul;   end;

end;

function prost(tt:int64):boolean;
var aa:extended; i,p,t:longint;  fl:boolean;
 begin
   fl:=true;
   aa:=tt;
   aa:=sqrt(aa);
   t:=round(aa);
   for i:=2 to t do if tt mod i=0 then fl:=false;

   prost:=fl;
 end;

function arcsin(pp:extended):extended;
var tt:extended;
begin
   if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)
   then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;
   tt:=1-pp*pp;
   if abs(tt)>=0 then
     begin
        arcsin:=arctan(pp/sqrt(tt));

     end;

end;

function gl(ch:char):boolean;
begin
 if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;

end;

function zaprmax(left,right:longint):int64;
begin
   if left>=right then zaprmax:=y[left] else
     begin
        if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else
         begin
          if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);
          if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);

         end;

     end;

end;

 function ff(gr:int64):boolean;

var ot,aa,bb,cc:int64; fl:boolean;
begin
  aa:=1; bb:=m;  cc:=aa; fl:=false;
  while abs(aa-bb)>1 do
    begin
       cc:=(aa+bb) shr 1;
       if y[cc]<gr then aa:=cc else bb:=cc;

    end;
  { writeln(' cc= ',cc);
  } cc:=min(cc+3,m+1);
   repeat dec(cc) until y[cc]<=gr;
   if y[cc]=gr then fl:=true else fl:=false;
  ff:=fl;
end;

begin
   { assign (input,'D:\Projects\input.txt');reset(input);
      assign (output,'D:\Projects\output.txt'); rewrite(output);
    }

      readln(t);
     v:=t;
     v:=sqrt(v)+eps;
     for i:=2 to trunc(v) do
       if t mod i=0 then begin flag:=true; ii:=i; goto 2; end;
 2:
     if not flag then writeln(1) else writeln(t div ii);

1:             close(output);
end.

var
  i,n,l:int64;

function _KTNT(x:int64):boolean;
  var
    i:longint;
  begin
    if x<=1 then exit(false);
    for i:=2 to trunc(sqrt(x)) do
      if (x mod i = 0) then exit(false);

    exit(true);
  end;

BEGIN

  read(n);

  if (n mod 2 = 0) then
    begin
      write(n div 2);
      halt;
    end;

  i:=1;
  while (i <= trunc(sqrt(n))) do
    begin
      if (n mod i = 0) then
        begin
          if (_KTNT(i) = true) then l:=i else
          if (_KTNT(n div i) = true) then
            begin
              l:=n div i;
              break;
            end;
        end;
      inc(i);
    end;
  write((n - l) div 2 + 1);

END.

var
  i,n,l:int64;

function _KTNT(x:int64):boolean;
  var
    i:longint;
  begin
    for i:=2 to trunc(sqrt(x)) do
      if (x mod i = 0) then exit(false);

    exit(true);
  end;

BEGIN

  read(n);

  if (n mod 2 = 0) then
    begin
      write(n div 2);
      halt;
    end;

  i:=1;
  while (i <= trunc(sqrt(n))) do
    begin
      if (n mod i = 0) then
        begin
          if (_KTNT(i) = true) then l:=i else
          if (_KTNT(n div i) = true) then
            begin
              l:=n div i;
              break;
            end;
        end;

      inc(i);
    end;
  writeln(l);
  write((n - l) div 2 + 1);

END.

var
  i,n,l:int64;

function _KTNT(x:int64):boolean;
  var
    i:longint;
  begin
    if x<=1 then exit(false);
    for i:=2 to trunc(sqrt(x)) do
      if (x mod i = 0) then exit(false);

    exit(true);
  end;

BEGIN

  read(n);

  if (n mod 2 = 0) then
    begin
      write(n div 2);
      halt;
    end;

  i:=1;
  while (i <= trunc(sqrt(n))) do
    begin
      if (n mod i = 0) then
        begin
          if (_KTNT(i) = true) then l:=i else
          if (_KTNT(n div i) = true) then
            begin
              l:=n div i;
              break;
            end;
        end;
      inc(i);
    end;
  writeln(l);
  write((n - l) div 2 + 1);

END.

uses math;
var f : text;
i,dem,res,j : longint;
prime : array[1..1000000] of longint;
kt : array[1..1000000] of boolean;
n : int64;
kq : qword;
procedure sang(X : longint);
begin
        i := 1;
        fillchar(kt,sizeof(kt),true);
        repeat
                inc(i);
                if kt[i] then
                        begin
                                inc(res);
                                prime[res] := i;
                                for j := 1 to x div i do kt[j*i] := false;
                        end;
        until i = x;
end;
begin
        readln(n);
        sang(min(1000000,n));
        dem := 1;
        if n>1 then
        begin
        for i := 1 to res do
                if n mod prime[i] = 0 then
                        begin
                                kq := n div prime[i];
                                break;
                        end;
        if kq=0 then kq := 1; {}
        end;
        writeln(kq);
end.

uses math;
var f : text;
i,dem,res,j : longint;
prime : array[1..1000000] of longint;
kt : array[1..1000000] of boolean;
n : int64;
kq : qword;
procedure sang(X : longint);
begin
        i := 1;
        fillchar(kt,sizeof(kt),true);
        repeat
                inc(i);
                if kt[i] then
                        begin
                                inc(res);
                                prime[res] := i;
                                for j := 1 to x div i do kt[j*i] := false;
                        end;
        until i = x;
end;
begin
     //   assigN(f,'SANG.INP');
      //  reset(f);
        readln(n);
        sang(min(1000000,n));
        dem := 1;
        repeat
                if n mod prime[dem] = 0 then
                        begin
                                kq := (n div prime[dem]-1)*prime[dem]+kq;
                                if n = prime[dem] then inc(kq);
                                n := (n div prime[dem]-1);
                                dem := 1 ;
                        end else inc(dem);
                if dem > res + 1 then
                        begin
                                inc(kq);
                                break;
                        end;
        until n <= 1;
      //  assigN(f,'SANG.OUT');
      //  rewrite(f);
        writeln(kq);
      //  close(f);
end.

uses math;
var f : text;
i,dem,res,j : longint;
prime : array[1..1000000] of longint;
kt : array[1..1000000] of boolean;
n : int64;
kq : qword;
procedure sang(X : longint);
begin
        i := 1;
        fillchar(kt,sizeof(kt),true);
        repeat
                inc(i);
                if kt[i] then
                        begin
                                inc(res);
                                prime[res] := i;
                                for j := 1 to x div i do kt[j*i] := false;
                        end;
        until i = x;
end;
begin
     //   assigN(f,'SANG.INP');
     //   reset(f);
        readln(n);
        sang(min(1000000,n));
        dem := 1;
        repeat
                if n mod prime[dem] = 0 then
                        begin
                                kq := (n div prime[dem]-1)*prime[dem]+kq;
                                n := (n div prime[dem]-1);
                                if n = prime[dem] then inc(kq);
                                dem := 1 ;
                        end else inc(dem);
                if dem > res + 1 then
                        begin
                                inc(kq);
                                break;
                        end;
        until n <= 1;
     //   assigN(f,'SANG.OUT');
     //   rewrite(f);
        writeln(kq);
     //   close(f);
end.

uses math;
var f : text;
i,dem,res,j : longint;
prime : array[1..1000000] of longint;
kt : array[1..1000000] of boolean;
n : int64;
kq : qword;
procedure sang(X : longint);
begin
        i := 1;
        fillchar(kt,sizeof(kt),true);
        repeat
                inc(i);
                if kt[i] then
                        begin
                                inc(res);
                                prime[res] := i;
                                for j := 1 to x div i do kt[j*i] := false;
                        end;
        until i = x;
end;
begin
        readln(n);
        if n>=2 then
        sang(min(1000000,n));
        dem := 1;
        kq := 0;
        if n>1 then
        begin
        for i := 1 to res do
                if n mod prime[i] = 0 then
                        begin
                                kq := n div prime[i];
                                break;
                        end;
        if kq=0 then kq := 1; {}
        end;
        writeln(kq);
end.

uses math;
var f : text;
i,dem,res,j : longint;
prime : array[1..1000000] of longint;
kt : array[1..1000000] of boolean;
n : int64;
kq : qword;
procedure sang(X : longint);
begin
        i := 1;
        fillchar(kt,sizeof(kt),true);
        repeat
                inc(i);
                if kt[i] then
                        begin
                                inc(res);
                                prime[res] := i;
                                for j := 1 to x div i do kt[j*i] := false;
                        end;
        until i = x;
end;
begin
        readln(n);
        sang(min(1000000,n));
        dem := 1;
        for i := 1 to res do
                if n mod prime[i] = 0 then
                        begin
                                kq := n div prime[i];
                                break;
                        end;
        if kq=0 then kq := 1; {}
        writeln(kq);
end.

var n,x,s,z:int64;
i:longint;
begin
//assign(input,'csjf.in');reset(input);
//assign(output,'csjf.out');rewrite(output);
readln(n);
while n mod 2<>0 do
  begin
  x:=n;z:=0;
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then
      begin
      z:=i;break;
      end;
  if z<>0 then n:=n div z
  else n:=0;
  s:=s+1;
  end;
s:=s+n div 2;
writeln(s);
close(input);close(output);
end.

var
bol:boolean;
n,ind:int64;
i,j:longint;
begin
readln(N);
for i:=2 to trunc(sqrt(n)) do begin
    if n mod i =0 then begin
    bol:=false;
        for j:=2 to trunc(sqrt(i)) do if i mod j= 0 then bol:=true;
        if bol=false then begin
            ind:=i;
            break;
        end;
    end;
    if ind<>0 then break;
end;

if ind=0 then writeln(1)
else
writeln(n div ind);
end.

var
bol:boolean;
n,ind:int64;
i,j:longint;
begin
readln(N);
for i:=2 to round(sqrt(n)) do begin
    if n mod i =0 then begin
    bol:=false;

        if bol=false then begin
            ind:=i;
            break;
        end;
    end;
   // if ind<>0 then break;
end;

if ind=0 then writeln(1)
else
writeln(n div ind);
end.

var n,count:int64;
    i:longint;
function check(n:int64):boolean;
var i:longint;
begin
    if (n=2) then exit(true);
    if (n mod 2=0) then exit(false);
    i:=3;
    while i<=trunc(sqrt(n)) do
        if (n mod i)=0 then exit(false)
        else i:=i+2;
    exit(true);
end;
begin
    read(n);
    count:=0;
    if (n mod 2=0) then count:=n shr 1
    else if check(n) then count:=1
    else
        begin
            i:=3;
            while i<=trunc(sqrt(n)) do
                 if ((n mod i)=0)and(check(i)) then
                    begin
                       count:=n div i;
                       break;
                    end
                 else i:=i+2;
        end;
    write(count);
end.

var n,count:int64;
    i:longint;
function check(n:int64):boolean;
var i:longint;
begin
    if (n=3)or(n=5) then exit(True);
    if (n mod 3=0)or(n mod 5=0) then exit(false);
    i:=1;
    while i<=(trunc(sqrt(n))div 6) do
        if ((n mod 6*i-1)=0)or ((n mod 6*i+1)=0)then exit(false)
        else i:=i+2;
    exit(true);
end;
begin
    read(n);
    count:=0;
    while n<>0 do
       begin
          if (n mod 2)=0 then
             begin count:=count + n div 2; n:=0; end
          else
          if check(n) then begin inc(count); n:=0; end
          else
             begin
                i:=3;
                while i<=trunc(sqrt(n)) do
                   if (n mod i=0)and(check(i)) then
                      begin
                         inc(count);
                         n:=n-i;
                         break;
                      end
                   else i:=i+2;
             end;
       end;
    write(count);
end.

var n,count:int64;
    i:longint;
function check(n:int64):boolean;
var i:longint;
begin
    if (n=2) then exit(true);
    if (n mod 2=0) then exit(false);
    i:=3;
    while i<=trunc(sqrt(n)) do
        if (n mod i)=0 then exit(false)
        else i:=i+2;
    exit(true);
end;
begin
    read(n);
    count:=0;
    if (n mod 2=0) then count:=count shr 1
    else if check(n) then count:=1
    else
        begin
            i:=3;
            while i<=trunc(sqrt(n)) do
                 if ((n mod i)=0)and(check(i)) then
                    begin
                       count:=n div i;
                       break;
                    end
                 else i:=i+2;
        end;
    write(count);
end.

var d,n:int64;
    i:longint;
begin
  read(n);
  if (n=2)or(n=3)then d:=n
  else
  begin
    d:=0;
    for i:=2 to round(sqrt(n))+1 do
      if n mod i = 0 then
      begin
        d:=i;
        break;
      end;
    if d = 0 then d:=n;
  end;
  if d = 0 then d:=n;
  if d=2 then writeln(round(n/2))
  else writeln(round(n/d)+round((n/d)/2));
end.

var d,n:int64;
    i:longint;
begin
  read(n);
  if (n=2)or(n=3)then d:=n
  else
  begin
    d:=0;
    for i:=2 to round(sqrt(n))+1 do
      if n mod i = 0 then
      begin
        d:=i;
        break;
      end;
    if d = 0 then d:=n;
  end;
  if d = 0 then d:=n;
  if d=2 then writeln(round(n/2))
  else writeln(round(n/d)+round(((n-d)/d)/2));
end.