This winter is so cold in Nvodsk! A group of n friends decided to buy k bottles of a soft drink called "Take-It-Light" to warm up a bit. Each bottle has l milliliters of the drink. Also they bought c limes and cut each of them into d slices. After that they found p grams of salt.To make a toast, each friend needs nl milliliters of the drink, a slice of lime and np grams of salt. The friends want to make as many toasts as they can, provided they all drink the same amount. How many toasts can each friend make?

The first and only line contains positive integers n, k, l, c, d, p, nl, np, not exceeding 1000 and no less than 1. The numbers are separated by exactly one space.

Print a single integer — the number of toasts each friend can make.

NoteA comment to the first sample: Overall the friends have 4 * 5 = 20 milliliters of the drink, it is enough to make 20 / 3 = 6 toasts. The limes are enough for 10 * 8 = 80 toasts and the salt is enough for 100 / 1 = 100 toasts. However, there are 3 friends in the group, so the answer is min(6, 80, 100) / 3 = 2.

program aaa;
Var n,k,l,c,d,p,nl,np:longint;
begin
     readln(n,k,l,c,d,p,nl,np);
     k:=(k*l) div nl;
     c:=c*d;
     p:=p div np;
     if (k<c)and(k<p)
     then writeln(k div n)
     else if (c<k)and(c<p)
          then writeln(c div n)
          else writeln(p div n);
end.

function get_min (a,b,c:longint):longint;
var min:longint;
begin
    min := a;
    if b < min then
        min := b;
    if c < min then
        min := c;
    get_min:=min;
end;

var n,k,l,c,d,p,nl,np:longint;
begin
    readln(n,k,l,c,d,p,nl,np);
    writeln(get_min((k*l) div nl,c*d,p div np) div n);
end.

{$APPTYPE CONSOLE}

var
  n, k ,l, c, d, p, nl, np, ans : integer;

function min (a, b : integer) : integer;
begin
  if a > b then
    result := b
  else
    result := a;

end;

begin
  //reset(input, 'input.txt');
  //rewrite(output, 'output.txt');
  read(n, k, l, c, d, p, nl, np);
  ans := min((k * l div nl) div n, min(c * d div n,(p div np) div n));
  write(ans);
end.

var n,k,l,c,d,p,nl,np:longint;

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

begin

readln(n,k,l,c,d,p,nl,np);
writeln(  min( min(  (k*l) div (nl*n), (c*d) div n ), p div (n*np) ));

end.

Var
  n,k,l,p,c,d,nl,np,a,b,o: longint;

Function minn(bb,aa: longint): longint;
begin
  if (aa < bb) then
    minn := aa
  else
    minn := bb;
end;

Begin
  read(n,k,l,c,d,p,nl,np);
  a := ((k*l) div nl);
  b := (p div np);
  o := (c*d);
  write((minn(a, minn(b, o))) div n);
  {if((a < b)and(a < o)) then
   begin
    write(a div n);
    exit;
   end;
  if((b < a)and(b < o)) then
   begin
    write(b div n);
    exit;
   end;
  if((o < b)and(o < a)) then
   begin
    write(o div n);
    exit;
   end;
  if((a = b)and(b = c)) then
    begin
      write(a div n);
      exit;
    end;
  write(0);}
End.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  k1:Int64;
  n,k,l,c,d,p,Ln,pn:Integer;
begin
  Readln(n,k,l,c,d,p,ln,pn);
  k1:=999999999;
  if (k*l)div(ln*n)<k1 then k1:=(k*l)div(ln*n);
  if (c*d)div n<k1 then k1:= (c*d)div n;
  if p div (pn*n)<k1 then k1:=p div (pn*n);
  Writeln(k1);
  Readln;
  Readln;
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;
var
 n, k, l, c, d, p, nl, np, min: integer;
begin
{$IFNDEF ONLINE_JUDGE}
  reset(input,'input.txt');
  rewrite(output,'output.txt');
{$ENDIF}
  read( n, k, l, c, d, p, nl, np);
  min:=(k*l) div (n*nl);
  if min>(c*d) div n then
   min:=(c*d) div n;
  if min>p div (np*n) then
   min:=p div (np*n);
  write(min);
{$IFNDEF ONLINE_JUDGE}
  close(input);
  close(output);
{$ENDIF}
end.

program A;

var
n,k,l,c,d,p,nl,np:integer;
s,kl,cd:integer;

begin

read(n,k,l,c,d,p,nl,np);
kl:=k*l;
cd:=c*d;
kl:=kl div nl;
p:=p div np;
if (kl<cd) and (kl<p) then s:=kl else if (cd<p) and (cd<kl) then s:=cd else if (p<kl) and (p<cd) then s:=p else s:=p;
s:=s div n;
writeln(s:9);
readln;

end.

uses math;
var n,k,l,c,d,p,nl,np:longint;
begin
    readln(n,k,l,c,d,p,nl,np);
    writeln(min(((k*l) div nl),min(c*d,(p div np))) div n);
end.

{$R+ Q+ I+}
{$APPTYPE CONSOLE}
uses
  SysUtils;
function min(a,b,c : integer) : integer;
var
  m : integer;
begin
     if a >= b then m := b
     else m := a;
     if m >= c then min := c
     else min := m;
end;
var
    n,k,d,p,nl,np,c,l,kol_l,kol_s,kol_g : integer;
begin
    read(n,k,l,c,d,p,nl,np);
    kol_g := (k * l) div nl;
    kol_l := c * d;
    kol_s := p div np;
    write(min(kol_g,kol_l,kol_s) div n);
end.

var  min, kols, koll, kolt, n, k, l, c, d, p, nl, np:longint;
begin
readln(n, k, l, c, d, p, nl, np);
kolt:=((k*l) div nl);
koll:=(c*d);
kols:=(p div np);
min:=100;
 if kolt<koll then min:=kolt
              else min:=koll;
 if min>kols then min:=kols;
min:=min div n;
writeln(min);
end.

var
 n,k,l,c,d,p,nl,np,x,y,z,yl,nm:longint;
begin
 readln(n,k,l,c,d,p,nl,np);
 yl:=k*l;
 nm:=c*d;
 x:=yl div nl div n;
 y:=nm div n;
 z:=p div np div n;
 if y<x then x:=y;
 if z<x then x:=z;
 writeln(x);
end.

var
 n,k,l,c,d,p,nl,np,Tost,vodka,zacus,sol:longint;
 f:boolean;
begin
 readln(n,k,l,c,d,p,nl,np);
 Vodka:=k*l;
 Zacus:=c*d;
 Sol:=p;
 Tost:=0;
  while not f do
  begin
   vodka:=vodka-n*nl;
   zacus:=zacus-n;
   sol:=sol-n*np;
   if (vodka>=0) and (zacus>=0) and (sol>=0) then inc(Tost)
   else begin writeln(Tost); f:=true; exit; end;
 end;
end.

program ProjectA;

{$APPTYPE CONSOLE}

uses
  SysUtils;

  function min(a,b:integer):integer;
  begin
  if a<b then result:=a else result:=b;
  end;

  var n,k,l,c,d,p,nl,np:integer;
  ans,ololo:integer;

begin
read(n); read(k); read(l); read(c); read(d); read(p); read(nl); read(np);
ololo:=min(c*d, min(k*l div nl, p div np));
ans:=ololo div n;
write(ans);readln;readln;
end.

var n,k,l,c,d,p,nl,np,a:longint;
function min(a,b:longint):longint; begin min:=a; if a>b then min:=b; end;
 begin read(n,k,l,c,d,p,nl,np); k:=(k*l) div nl; c:=c*d; p:=p div np;
 write(min(min(k,c),p) div n); end.

program z1;
uses math;
var
  n, k, l, c, d, p, nl, np : longint;
begin
  readln(n, k, l, c, d, p, nl, np);
  writeln(min(min(k * l div nl, p div np), c * d) div n);
end.

program A;
uses
  SysUtils;
var n, k, l, c, d, p, nl, np:integer;
    drink,lime,eat:longint;
function min(a,b,c:longint):longint;
begin
 if a<b
 then begin if a<c then min:=a
                   else min:=c end
 else begin if b<c then min:=b
                   else min:=c end;

end;
begin
 //assign(input,'input.txt');
 //assign(output,'output.txt');
 readln(n, k, l, c, d, p, nl, np);
 drink:=(k*l) div nl;
 lime:=c*d;
 eat:=p div np;
 write(min(drink,lime,eat)div n);
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils, Math;

var
  i, j, n, res, k, l, p, nl, np, d, c : int64;
  a : array[1..10000] of integer;

begin

  read(n, k, l, c, d, p, nl, np);
  writeln(min(k * l div nl, min(c * d, p div np)) div n);

  readln;readln;
end.

program Gazirovka;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;

var
 n,k,l,c,d,p,nl,np:smallint;
 tl,tc,tp,al,min1:integer;
 t:integer;
begin
  { TODO -oUser -cConsole Main : Insert code here }
 readln(n,k,l,c,d,p,nl,np);
 al:=k*l;
 tl:=al div nl;
 tc:=c*d;
 tp:=p div np;
 min1:=min(tl,tp);
 t:=min(min1,tc);
 t:= t div n;
 writeln(t);
 readln;
end.

{$APPTYPE CONSOLE}

uses
  SysUtils,math;
var wq,n,k,l,c,d,p,nl,np:integer;
begin
 readln(n,k,l,c,d,p,nl,np);
 wq:=min(k*l div nl,min(c*d,p div np)) div n;
 writeln(wq);
end.

program pr1;

{$APPTYPE CONSOLE}

const nn=10001;
 eps=0.000000001;  nnn=200;
 label 1,2;
var step,i,j:longint;
d,c,nl,np,s,m,s1,mmin,mmax,imin,imax,ii,x1,y1,n,ot,modul,p1,p2,k,l,r,izm,t,p,k1,k2,a2:longint;

a,b,h,dl,pr,st:array [-1..1000] of longint;
pp,dost:array[0..1000] of longint;
ch:char;
b1:array [0..100000] of char;
sv:array [-1..10000 ] of boolean;
uu,uu1:array[0..200] of boolean;
flag2,flag1,flag:boolean;
verot:double;
ss,namemin:string;
str:array[0..20] of string;
function min (a,b:longint):longint;begin min:=b;if a<b then min:=a;  end;
function max (a,b:longint):longint;begin max:=b;if a>b then max:=a;  end;

function nod(a,b:longint):longint; var p,t:longint;
begin if (a>0)and(b>0) then
   begin while (b>0) do begin t:=a mod b;a:=b;b:=t;    end;
    p:=a;
   end else if a=0 then p:=b else p:=a;
nod:=p;
end;

{function diam(a,b:mas;n:longint):longint;
var i0,t,i,j,k:longint; kver:mas; sv:mas2;
 begin
   for i:=1 to n do for j:=1 to n-1 do
   if a[j]=i then  begin  inc(kver[i]); sv[i,kver[i]]:=b[j];  end;
 for i:=1 to n do for j:=1 to n-1 do
   if b[j]=i then  begin  inc(kver[i]); sv[i,kver[i]]:=a[j];  end;
 for i:=1 to n do write(kver[i],' ');writeln;  writeln;
 for i:=1 to n do begin  for j:=1 to kver[i] do write(i,'-',sv[i,j],'    ');writeln;  end;

for i0:=1 to 1 do
  begin  for i:=1 to n do sm[i]:=false; for i:=1 to n do dist[i]:=1000;
  sm[i0]:=true; dist[i0]:=0; kol:=1;

  end;

diam:=t;
 end; }

begin
{assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
}    readln(n,k,l,c,d,p,nl,np);
  i:=(c*d); j:=p div np; t:=(k*l) div nl;
  {writeln(i,' ',j,' ',t); }
  i:=min(i,j);t:=min(i,t);
  writeln(t div n);

      1: close (output);
  end.

uses math;
var

    a, n, k, l, c, d, p, nl, np, lim, sol: longint;

begin
//    reset(input, 'a.in');
 //  rewrite(output, 'a.out');

    read(n, k, l, c, d, p, nl, np);

    a := k * l div nl;
    lim := c * d;
    sol := p div np;

    write(min(a, min(lim, sol)) div n);

end.

Var kol,n,k,l,c,d,p,nl,np:LongInt;
Begin
     Readln (n,k,l,c,d,p,nl,np);
     k:=k*l;
     c:=c*d;
     kol:=0;
     While (k>=nl) and (c>0) and (p>=np) do
     Begin
          k:=k-nl;
          Dec (c);
          p:=p-np;
          Inc (kol);
     End;
     kol:=kol div n;
     Writeln (kol);
End.

program aleksa;
var n,i,j,br,sum,sum2,sum3,res,min:Longint;
    niz:array[1..100] of Integer;
    s:String;
begin
    for i:=1 to 8 do read(niz[i]);
    sum:=niz[2]*niz[3] div niz[7];
    min:=sum;
    sum2:=niz[4]*niz[5];
    if sum2<min then min:=sum2;
    sum3:=niz[6] div niz[8];
    if sum3<min then min:=sum3;
    res:=min div niz[1];
    writeln(res);
end.

program aa;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
n, k, l, c, d, p, nl, np, r, s1 , s2 , s3 : integer;

begin
  readln(n, k, l, c, d, p, nl, np);
  s1 := k * l;
  s2 := c * d;
  s3 := p;
  r := 0;
  while (s1 >= 0)and(s2 >= 0)and(s3 >= 0)do begin
    inc(r);
    s1 := s1 - n*nl;
    s2 := s2 - n;
    s3 := s3 - n*np;
  end;
  dec(r);
  writeln(r);
end.

program Project2;

{$APPTYPE CONSOLE}
{$A+,B-,D-,E+,F+,G-,I-,L-,N+,O-,R-,Q-,V+,X+}

uses
  SysUtils,
  Math;

var
  n, k, l, c, d, p, nl, np, x, y, z: integer;

begin
  //Reset(input, 'input.txt');
  //Rewrite(output, 'output.txt');

  read(n, k, l, c, d, p, nl, np);
  c := c * d;
  x := (k * l) div (n * nl);
  y := c div n;
  z := p div (n * np);
  write(min(x, min(y, z)));

end.

Uses Math;
var
	n, k, l, c, d, p, nl, np : longint;

begin
//	reset(input, 'a.in');	rewrite(output, 'a.out');
	read(n, k, l, c, d, p, nl, np);

	write(min(min(k*l div nl, c*d), p div np) div n);
end.

uses math;
var
  a,l,s,d,f,g,h,k:integer;
begin
  read(a,l,s,d,f,g,h,k);
  write((min((((l*s) div h)),min(((d*f)),((g div k))))) div a);
end.

var a,b,c,d,f,i,j,k,n,n1:longint;
function min(a,a1:longint):longint;
begin
if a>a1 then min:=a1 else min:=a
end;
begin
readln(a,b,c,d,f,k,n,n1);
b:=b*c;
c:=d*f;
d:=k;
writeln(min(min((b div a) div n,c div a),(d div n1) div a));
end.

program Project4;
{$APPTYPE CONSOLE}

var n, k, l, c, d, p, nl, np: integer;

begin
  read(n,k,l,c,d,p,nl,np);
  if ( (k * l) DIV nl < c * d) AND ( (k * l) DIV nl < p DIV np) then
    write( (k * l) DIV nl DIV n) else
  if ( (k * l) DIV nl > c * d) AND ( c * d < p DIV np) then
    write( (c * d) DIV n ) else
  if ( p DIV np < c * d) AND ( c * d > p DIV np) then
    write( p DIV np DIV n ) else
  write( p DIV np DIV n );

end.

function min(a,b:integer):integer;
begin
if a>b then
min:=b
else
min:=a;
end;

var n, k, l, c, d, p, nl, np,w1,w2,w3,w:integer;
begin
read(n, k, l, c, d, p, nl, np);
w:=(k*l)div nl ;
w1:=c*d;
w2:=p div np;
w3:=min(w,w1);
w3:=min(w2,w3);
writeln(w3 div n);
end.

Program SoftDrinking;
uses math;
var n,k,l,c,d,p,nl,np,ans:longint;
begin   //assign(input,'151A.inp'); reset(input);
        //assign(output,'151A.out'); rewrite(output);
        readln(n,k,l,c,d,p,nl,np);
        ans:=min(k*l div nl,min(c*d,p div np));
        writeln(ans div n);
        //close(input); close(output);
end.

program Project_151A;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var

  fi,fo:Text;
  f,n, k, l, c, d, p, nl, np,a,b,min,ans:Integer;

begin

read( n, k, l, c, d, p, nl, np );
a:=(c*d) ;
b:=p div np;
f:=k*l div nl;
if (a<=b ) and (a<=f) then min:=a;
if (b<=a ) and (b<=f) then min:=b;
if (f<=b ) and (f<=a) then min:=f;
ans:=min div n;
write( ans);

end.

var   min,  banhtt,salt,n,l,k,c,d,p,nl,np,thetich,solimes,kq:longint;
begin
        assign(input,'');
        reset(input);
        readln(n,l,k,c,d,p,nl,np);
        thetich:=l*k;
        solimes:=c*d;
        kq:=0;
        banhtt:=thetich div nl;
        salt:=p div np;
        min:=10000;
        if salt<min then min:=salt;
        if banhtt<min then min:=banhtt;
        if solimes<min then min:=solimes;
        kq:=min div n;

        write(kq);
        close(input);
end
.

var n,k,l,c,d,p,nl,np,a:longint;
function min(a,b:longint):longint; begin min:=a; if a>b then min:=b; end;
 begin read(n,k,l,c,d,p,nl,np); k:=(k*l) div nl; c:=c*d; p:=p div np;
 write(min(min(k,c),p) div n); end.

var
x,p,l,k,nl,np,raz,d,j,m,i,R,r2,n:longint;
y,s1,q1,z1,b,c:longint;
a:array  [1..1000] of longint;
s,q,z:string;
{input,output:text;}

function max(a,b:longint):longint;
begin
if a< b then max:=a else max:=b;
end;

begin

{ assign(input, 'input.txt'); reset(input);
  assign(output, 'output.txt'); rewrite(output);
 }

read (n,k,l,c,d,p,nl,np);

c:=c*d;
x:=max(p div (n*np),max( (k*l) div(n*nl),c div n));
if x <=0 then write (0) else write (x);
end.

var
 n,k,l,c,d,p,nl,np,ts,tl,tp,min : integer ;

begin
 read (n,k,l,c,d,p,nl,np) ;
 ts := (k * l) div nl ;
 tl := c * d ;
 tp := p div np ;
 min := 1001 ;
 if ts < min then
  min := ts ;
 if tl < min then
  min := tl ;
 if tp < min then
  min := tp ;
 writeln (min div n) ;
end.

uses math;
var
    n,k,l,c,d,p,nl,np:longint;
begin
    readln(n,k,l,c,d,p,nl,np);
    writeln(min(min(k*l div nl,p div np),c*d)div n);
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;
  var
  i,j,k,l,m,p,d,c,nl,np,n,xml,xl,xp:  int64;
begin
 read(n,k,l,c,d,p,nl,np);
 xml:=(k*l)div nl;
 xl:=c*d;
  xp:=p div np;
 i:=10000000000000000;
  if i> (xml div n) then i:=(xml div n);
   if i> (xp div n) then i:=(xp div n);
    if i> (xl div n) then i:=(xl div n);
   write(i);

end.

program a1;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Math;
var
  n,m,a,ot,l,np,p,nl,b,c,d,k,i,j:longint;
  s:string;
  f:boolean;
  x,y,r:array[1..100000]of longint;
begin
{  reset(input,'input.txt');
  rewrite(output,'output.txt'); }
  read(n,k,l,c,d,p,nl,np);
  write(min(min(k*l div nl, c*d), (p div np)) div n);
end.

uses math;

var
 n,m,k,l,w,s,j,i,nl,np,c,d,a1,a2,a3,p:longint;
begin
 readln(n,k,l,c,d,p,nl,np);
 a1:=(k*l)div nl;
 a2:=(c*d);
 a3:=p div np;
 writeln(min(a3,min(a1,a2)) div n);
end.

uses math;
var
  n, k, l, c, d, p, nl, np,bbb, lol, b : integer;

begin
 read(n, k, l, c, d, p, nl, np);

 bbb := k*l ;
 bbb := bbb div nl;
 //b := bbb div n;
 lol := min(bbb,(min((c*d),(p div np))));
write(lol div n);
end.

Program _151A;
var
  n, k, l, c, d, p, nl, np, gas, lime, salt, tost : longint;
function min(a, b : longint) : longint;
  begin
    if a < b
       then min := a
       else min := b;
  end;
begin
  read(n, k, l, c, d, p, nl, np);
  gas := k * l div nl;
  lime := c * d;
  salt := p div np;
  tost := min(min(gas, lime),salt);
  write(tost div n);
end.

program soft_drink;

Function mina(a,b:longint):longint;
begin
  if (a<b) then mina:=a  Else mina:=b;
end;

Function min (a,b,c:longint):longint;
begin
  min:=mina(mina(a,b),c);
end;

Var n,k,l,c,d,p,nl,np,res,t,la,s:longint;

Begin
  Readln(n,k,l,c,d,p,nl,np);
  res:=(min((k*l) div nl,c*d,p div np)) div n;
  writeln(res);

end.

{$APPTYPE CONSOLE}

uses SysUtils, Math;

var  n, k, l, c, d, p, nl, np : integer;

procedure r1;
begin
  read(n, k, l, c, d, p, nl, np);
end;

procedure ex1;
var a, b, x: integer;
begin
  a := (k * l) div nl;
  b := c * d;
  x := p div np;
  write(min(a, min(b, x)) div n);
end;

begin
  r1;
  ex1;
end.

program aleksa;
var n,i,j,br,sum,sum2,sum3,res,min:Longint;
    niz:array[1..100] of Integer;
    s:String;
begin
    for i:=1 to 8 do read(niz[i]);
    sum:=niz[2]*niz[3] div niz[7];
    min:=sum;
    sum2:=niz[4]*niz[5];
    if sum2<min then min:=sum2;
    sum3:=niz[6] div niz[8];
    if sum3<min then min:=sum3;
    res:=min div niz[1];
    writeln(res);
end.

var p,min,d,c,np,nl,n,i,l,k,j,m:longint;
begin
read(n,k,l,c,d,p,nl,np);
min:=k*l div nl;
if min>c*d then min:=c*d;
if min>p div np then min:=p div np;
writeln(min div n);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils, Math;

var
  n, k, l, c, d, p, nl, np: longint;

begin
  read(n, k, l, c, d, p, nl, np);

  write((min(min((k*l) div nl, c*d), p div np))div n);

end.

Var
    n, k, l, c, d, p, nl, np: Int64;

Begin
    Read(n, k, l, c, d, p, nl, np);
    Write(min((k*l) div (n*nl), min((c*d) div n, p div (n*np))))
End.

uses math;
var n,k,l,c,p,d,nl,np:integer;
begin
        read(n,k,l,c,d,p,nl,np);
        write(min((k*l) div nl,min(c*d,p div np)) div n);
end.

var n,k,j,c,d,p,nj,np,min,tg,tl,ts: int64;
begin
readln (n,k,j,c,d,p,nj,np);
tg:=(k*j) div nj ;
tl:=(c*d);
ts:=(p) div np ;
min:=ts div n;
if ((tg<tl) and (tg<ts)) then min:=tg div n;
if ((tl<tg) and (tl<ts)) then min:=tl div n;
writeln (min);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils, Math;

var
  n, k, l, c, d, p, nl, np, r: integer;

begin
  {reset(input, 'input.txt');
  rewrite(output, 'output.txt');}

  readln(n, k, l, c, d, p, nl, np);

  k := k * l div nl;
  c := c * d;
  p := p div np;

  k := min(min(k, c), p);

  writeln(k div n);

end.

Var i,n, k, l, c, d, p, nl, np:longint;
otv:int64;
begin
  read (n, k, l, c, d, p, nl, np);
 k:=(k*l) div nl;
 c:=c*d;
 p:=p div np;
 if (k<c) and(k<p) then otv:=k div n else
 if (c<k) and(c<p) then otv:=c div n else
 otv:=p div n;
writeln (otv);
end.

{$APPTYPE CONSOLE}
{$IFNDEF ONLINE_JUDGE}
    {$R+,S+,Q+,I+,C+,M+,H+,O+}
{$ELSE}
    {$R-,S-,Q-,I-,C+,M-,H+,O+}
{$ENDIF}

uses
    SysUtils, Math;

var
    n, k, l, c, d, p, nl, np, av, ad, ap : int64;

begin
{$IFNDEF ONLINE_JUDGE}
    reset(input, 'input.txt');
    rewrite(output, 'output.txt');
{$ENDIF}
    read(n, k, l, c, d, p, nl, np);
    av := k * l div nl;
    ad := c * d;
    ap := p div np;
    write(min(av, min(ad, ap)) div n);
end.

program z1;
uses math;
var
  n, k, l, c, d, p, nl, np : longint;
begin
  readln(n, k, l, c, d, p, nl, np);
  writeln(min(min(k * l div nl, p div np), c * d) div n);
end.

program solveA;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Math;

var
  n, k, l, c, d, p, nl, np: integer;
begin
  readln(n, k, l, c, d, p, nl, np);
  writeln(min(min((k*l) div nl, c*d), p div np) div n  );
  readln;readln;
end.

program gas;
var n,k,l,c,d,p,nl,np,i,all_gas,tost1,tost2,tost3,tost4:integer;

begin
  readln(n,k,l,c,d,p,nl,np);
  all_gas:=k*l;
  tost1:=all_gas div nl;
  tost2:=c*d;
  tost3:=p div np;
  if tost1 < tost2 then begin
    if tost1 < tost3 then writeln(tost1 div n) else writeln(tost3 div n)
  end else begin
    if tost2 < tost3 then writeln(tost2 div n) else writeln(tost3 div n)
  end;
end.

program Problem_A;

{$APPTYPE CONSOLE}

var n,k,l,c,d,p,nl,np,min:integer;

begin
readln(n,k,l,c,d,p,nl,np);
min:=(k*l) div (n*nl);
if c*d div n<min then min:=c*d div n;
if (p div (n*np))<min then min:=(p div (n*np));
write(min);
readln;
readln;

end.

program a1;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Math;
var
  n,m,a,ot,l,np,p,nl,b,c,d,k,i,j:longint;
  s:string;
  f:boolean;
  x,y,r:array[1..100000]of longint;
begin
{  reset(input,'input.txt');
  rewrite(output,'output.txt'); }
  read(n,k,l,c,d,p,nl,np);
  write(min(min(k*l div nl, c*d), (p div np)) div n);
end.

program ex;
var n,k,l,c,d,p,nl,np:integer;
    v,dol,sol,min :real;
begin
readln(n,k,l,c,d,p,nl,np);

v:=k*l/nl/n;
dol:=c*d/n;
sol:=p/np/n;

if v>dol then min:=dol else min:=v;
if min>sol then min:=sol;
min:=trunc(min);
writeln(min:0:0);

end.

function get_min (a,b,c:longint):longint;
var min:longint;
begin
    min := a;
    if b < min then
        min := b;
    if c < min then
        min := c;
    get_min:=min;
end;

var n,k,l,c,d,p,nl,np:longint;
begin
    readln(n,k,l,c,d,p,nl,np);
    writeln(get_min((k*l) div nl,c*d,p div np) div n);
end.

var
 n,k,l,c,d,p,nl,np,x,y,z,yl,nm:longint;
begin
 readln(n,k,l,c,d,p,nl,np);
 yl:=k*l;
 nm:=c*d;
 x:=yl div nl div n;
 y:=nm div n;
 z:=p div np div n;
 if y<x then x:=y;
 if z<x then x:=z;
 writeln(x);
end.

program taskA;
var
   n, k, l, c, d, p, nl, np :longint;
   i,max:longint;
   a:array[1..6] of longint;
begin
  read(n, k, l, c, d, p, nl, np);
  a[1]:=k*l div nl;
  a[2]:=c*d;
  a[3]:=p div np;
  for i:=1 to 3 do
  a[i+3]:=a[i] div n;

  max:=a[4];
  for i:=5 to 6 do
  if a[i]<max then max:=a[i];
  writeln(max);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;
var
n,k,l,c,d,p,nl,np,i1,i2,i3,j:Integer;
begin
Readln(n,k,l,c,d,p,nl,np);
i1:=(k*l) div (nl*n);
i2:=(c*d) div n;
i3:=p div (np*n);
i1:=min(i1,i2);
i1:=min(i1,i3);
Writeln(i1 );
Readln(i1);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  k1:Int64;
  n,k,l,c,d,p,Ln,pn:Integer;
begin
  Readln(n,k,l,c,d,p,ln,pn);
  k1:=999999999;
  if (k*l)div(ln*n)<k1 then k1:=(k*l)div(ln*n);
  if (c*d)div n<k1 then k1:= (c*d)div n;
  if p div (pn*n)<k1 then k1:=p div (pn*n);
  Writeln(k1);
  Readln;
  Readln;
end.

uses math;
var
    n,k,l,c,d,p,nl,np:longint;
begin
    readln(n,k,l,c,d,p,nl,np);
    writeln(min(min(k*l div nl,p div np),c*d)div n);
end.

Uses Math;
var
	n, k, l, c, d, p, nl, np : longint;

begin
//	reset(input, 'a.in');	rewrite(output, 'a.out');
	read(n, k, l, c, d, p, nl, np);

	write(min(min(k*l div nl, c*d), p div np) div n);
end.

var
n,k,l,c,d,p,nl,np:longint;

Function min(a,b,c:longint):longint;
var ans:longint;
begin
 if a>b then ans:=b else ans:=a;
 if c<ans then ans:=c;
 min:=ans;
end;

begin
//assign(input,'input.txt'); reset(input);
//assign(output,'output.txt'); rewrite(output);
readln(n,k,l,c,d,p,nl,np);
k:=k*l;
k:=k div nl;
c:=c*d;
p:=p div np;
writeln(min(k,c,p) div n);
//close(input); close(output);
end.

program gazirovkopitie;
var n,k,l,c,d,p,nl,np,min : longint;
begin
read(n,k,l,c,d,p,nl,np);
k:=(k*l) div nl;
c:=c*d;
p:=p div np;
min:=k;
if c < min then min:=c;
if p < min then min:=p;
write(min div n);
end.

program prob_a;

{$APPTYPE CONSOLE}

uses
  math,
  SysUtils;

var
  sol,n,k,l,p,d,c,nl,np:longint;

begin
  read(n,k,l,c,d,p,nl,np);
  sol:=min((k*l div nl)div n,(c*d)div n);
  writeln(min(sol,(p div np)div n));
  readln(k);
end.

const
       fi='';
       fo='';
var
       a,b,c,d,e,m,g,h,kq:longint;
       f:text;
procedure nhap;
begin
       assign(f,fi);
       reset(f);
       readln(f,a,b,c,d,e,m,g,h);
       close(f);
end;
function min(i,j,k:longint):longint;
begin
       if (i<=j) and (i<=k) then exit(i);
       if (j<=k) and (j<=i) then exit(j);
       if (k<=i) and (k<=j) then exit(k);
end;
procedure xuli;
var
       i,j,k:longint;
begin
       i:=(b*c) div g;
       j:=(d*e);
       k:=m div h;
       kq:=min(i,j,k);
       kq:=kq div a;
end;
procedure xuat;
begin
       assign(f,fo);
       rewrite(f);
       writeln(f,kq);
       close(f);
end;
begin
       nhap;
       xuli;
       xuat;
end.

uses math;
var
n,k,l,c,d,p,nl,np:longint;
begin
readln(n,k,l,c,d,p,nl,np);
writeln(min(min(k*l div nl,p div np),c*d) div n);
end.

uses math;
var
  n,k,l,c,d,p,nl,np:longint;
begin
  readln(n,k,l,c,d,p,nl,np);
  writeln(min(min(k*l div nl,p div np),c*d) div n);
end.

var a,b,c,d,e,f,g,h,fs:longint;
function sd (n,k,l,c,d,p,nl,np: longint):longint;
var v,t,a,minn:longint;
begin
    begin
        v:=(k*l) div nl;
        t:=c * d;
        a:=p div np;
    end;
    minn:=v;
    if (minn > t) then minn:=t;
    if (minn > a) then minn:=a;
    exit(minn div n);
end;
begin
    readln(a,b,c,d,e,f,g,h);
    fs:=sd(a,b,c,d,e,f,g,h);
    writeln(fs);
end.

program solveA;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Math;

var
  n, k, l, c, d, p, nl, np: integer;
begin
  readln(n, k, l, c, d, p, nl, np);
  writeln(min(min((k*l) div nl, c*d), p div np) div n  );
  readln;readln;
end.

program n_2;
var  n, k, l, c, d, p, nl, np: real;
v, t, laim, s, min: real;
begin
readln(n, k, l, c, d, p, nl, np);
v:=k*l;
t:=v/nl;
laim:=c*d;
s:=p/np;
min:=t+laim+s;
if (t/n) < min then min:=(t/n);
if (laim/n) < min then min:=(laim/n);
if (s/n) < min then min:=(s/n);
write(trunc(min));
end.

var
min,ans,n,k,l,c,d,p,nl,np,kl:longint;
begin
readln(n,k,l,c,d,p,nl,np);
kl:=k*l;
min:=kl div nl;
if c*d<min then min:=c*d;
if p div np<min then min:=p div np;
//writeln(min);
min:=min div n;
writeln(min);
end.

program Project1;

{$APPTYPE CONSOLE}

var n, k, l, c, d, p, nl, np,n1,n2,n3:integer;
begin
  readln(n, k, l, c, d, p, nl, np);
  n1:=(k*l)div nl;
  n2:=c*d;
  n3:=p div np;
  if (n1<=n2)and(n1<=n3) then writeln(n1 div n)
  else if (n2<=n3) and (n2<=n1) then writeln(n2 div n)
       else writeln(n3 div n);

end.

program A;

var
n,k,l,c,d,p,nl,np:integer;
s,kl,cd:integer;

begin

read(n,k,l,c,d,p,nl,np);
kl:=k*l;
cd:=c*d;
kl:=kl div nl;
p:=p div np;
if (kl<cd) and (kl<p) then s:=kl else if (cd<p) and (cd<kl) then s:=cd else if (p<kl) and (p<cd) then s:=p else s:=p;
s:=s div n;
writeln(s:9);
readln;

end.

uses math;
var n,k,l,c,d,nl,np,a,b,p,q:longint;
begin
     //assign(input,'soft_drinking.inp');
     //reset(input);
     //assign(output,'soft_drinking.out');
     //rewrite(output);
     readln(n,k,l,c,d,p,nl,np);
     a:=(k*l) div nl;
     b:=c*d;
     q:=p div np;
     write(min(a,min(b,q)) div n);
end.

var
    n,l,k,nl,d,p,np,i,i2,j,c:integer;
    a:array [1..3] of integer;
begin
    read(n,k,l,c,d,p,nl,np);
    a[1]:=(k*l) div nl;
    a[2]:=c*d;
    a[3]:=p div np;
    for i:=1 to 2 do
    begin
        for i2:=1 to 2 do
        begin
            if a[i2]>=a[i2+1] then
            begin
                j:=a[i2];
                a[i2]:=a[i2+1];
                a[i2+1]:=j;
            end;
        end;
   end;
   writeln(a[1] div n);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils, Math;

var
  n, k, l, c, d, p, nl, np: longint;

begin
  read(n, k, l, c, d, p, nl, np);

  write((min(min((k*l) div nl, c*d), p div np))div n);

end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
n,k,l,c,d,p,nl,np,z,x,y,kl,cd:integer;

begin
readln(n,k,l,c,d,p,nl,np);
kl:=k*l;
z:=kl div nl;
cd:=c*d;
x:=p div np;
if z>cd then
y:=cd
else
y:=z;
if y>x then
y:=x div n
else
y:=y div n;
writeln(y);
  { TODO -oUser -cConsole Main : Insert code here }
end.

var
 n,k,l,c,d,p,nl,np,Tost,vodka,zacus,sol:longint;
 f:boolean;
begin
 readln(n,k,l,c,d,p,nl,np);
 Vodka:=k*l;
 Zacus:=c*d;
 Sol:=p;
 Tost:=0;
  while not f do
  begin
   vodka:=vodka-n*nl;
   zacus:=zacus-n;
   sol:=sol-n*np;
   if (vodka>=0) and (zacus>=0) and (sol>=0) then inc(Tost)
   else begin writeln(Tost); f:=true; exit; end;
 end;
end.

program Project1;

{$APPTYPE CONSOLE}
{$O-}
uses
  SysUtils,
  Math;

var
  n, l, c, d, k, nl, np, res1, res2, res3, p: integer;

begin
  //reset(input, 'input.txt');  rewrite(output, 'output.txt');
  readln(n, k, l, c, d, p, nl, np);
  res1 := k * l div nl;
  res2 := c * d;
  res3 := p div np;
  writeln(min(min(res1, res2), res3) div n);
  //close(input);  close(output);
end.

var i,j,n,k,l,c,d,p,nl,np,a1,a2,a3,max:integer;
begin
readln (n,k,l,c,d,p,nl,np);
a1:=k*l div nl;
a2:=c*d;
a3:=p div np;
if a1<=a2 then
max:=a1
else
max:=a2;
if a3<max then
max:=a3;
writeln (max div n);
end.

var n,k,l,c,d,p,nl,np:longint;

 procedure InputData;
 begin
 readln(n,k,l,c,d,p,nl,np);
 end;

 function min(x,y:longint):longint;
 begin
 if x<y then min:=x
        else min:=y;
 end;

 procedure OutputData;
 begin
 writeln(min(k*l div 3,min(c*d,p div np)) div n);
 end;

begin
InputData;
OutputData;
end.

var
  n, k, l, c, d, p, nl, np, s, g, min: uint64;

begin
  read(n, k, l, c, d, p, nl, np);
  g := (k * l) div nl;
  s := c * d;
  p := p div np;
  min := s;
  if g < min then
    min := g;
  if p < min then
    min := p;
  if min div n > -1  then
    write(min div n)
  else
    write('0');
end.

program gas;
var n,k,l,c,d,p,nl,np,i,all_gas,tost1,tost2,tost3,tost4:integer;
begin
  readln(n,k,l,c,d,p,nl,np);
  all_gas:=k*l;
  tost1:=all_gas div nl;
  tost2:=c*d;
  tost3:=p div nl;
  if tost1 < tost2 then begin
    if tost1 < tost3 then writeln(tost1 div n) else writeln(tost3 div n)
  end else begin
    if tost2 < tost3 then writeln(tost2 div n) else writeln(tost3 div n)
  end;
end.

function min(a,b:integer):integer;
begin
if a>b then
min:=b
else
min:=a;
end;

var n, k, l, c, d, p, nl, np,w1,w2,w3,w:integer;
begin
read(n, k, l, c, d, p, nl, np);
w:=(k*l)div n ;
w1:=c*d;
w2:=p div np;
w3:=min(w,w1);
w3:=min(w2,w3);
writeln(w3 div n);
end.

uses math;
VAR N,K,L,C,D,P,NL,NP,X,Z,Y:LONGINT;
begin
readln(N,K,L,C,D,P,NL,NP);
Z:=(K*L) DIV NL;
y:=C*D;
X:=P DIV NP;
WRITE(MIN(MIN(Z,Y),X)DIV 3);
END.

program soft_drink;

Function min(a,b,c:longint):longint;
begin
  if (a<b) and (a<c) then min:=a;
  if (b<a) and (b<c) then min:=b;
  if (c<a) and (c<b) then min:=c;
end;

Var n,k,l,c,d,p,nl,np,res,t,la,s:longint;

Begin
  Readln(n,k,l,c,d,p,nl,np);
  t:=(k*l) div n;
  la:=d*c;
  s:=p div np;
  res:=(min(t,la,s)) div n;
  writeln(res);

end.

program contest107;

{$APPTYPE CONSOLE}

uses
  SysUtils, Math;

var n, k, l, c, d, p, nl, np,ll,laim,sol,ans : longint;

function min (a,b,c : longint) : longint;
begin
  if (a < b) and (a < c) then
    min := a;
  if (b < a) and (b < c) then
    min := b;
  if (c < b) and (c < a) then
    min := c;

end;

begin
//  reset(input,'input.txt');
//  rewrite(output,'output.txt');

  readln(n, k, l, c, d, p, nl, np);
  ll := (k * l) div nl;
  laim := c * d;
  sol := p div np;
  ans := min(ll,sol,laim) div n;
  writeln(ans);

end.

program taskA;
var
   n, k, l, c, d, p, nl, np :integer;
   i,max:integer;
   a:array[1..6] of integer;
begin
  read(n, k, l, c, d, p, nl, np);
  a[1]:=k*l div nl;
  a[2]:=c*d;
  a[3]:=p div np;
  for i:=1 to 3 do
  a[i+3]:=a[i] div n;

  max:=a[4];
  for i:=5 to 6 do
  if a[i]<max then max:=a[i];
  writeln(max);
end.

program Gazirovka;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;

var
 n,k,l,c,d,p,nl,np:smallint;
 tl,tc,tp,al,min1:smallint;
 t:smallint;
begin
  { TODO -oUser -cConsole Main : Insert code here }
 writeln('Input n, k, l, c, d, p, nl, np');
 readln(n,k,l,c,d,p,nl,np);
 al:=k*l;
 tl:=al div n;
 tc:=c*d;
 tp:=p div np;
 min1:=min(tl,tc);
 t:=min(min1,tp) div n;
 writeln('tosts = ',t);
 readln;
end.

uses math;
var
     N,K,L,C,D,P,NL,NP,Ans,X,Y,Z:Longint;
begin
     Readln(N,K,L,C,D,P,NL,NP);
     X:=(K*L) div NL;
     Y:=C*D;
     Z:=P div NP;
     Ans:=min(X,Y);
     Writeln(min(Ans,Z));
 end.

const
       fi='';
       fo='';
var
       a,b,c,d,e,m,g,h,kq:longint;
       f:text;
procedure nhap;
begin
       assign(f,fi);
       reset(f);
       readln(f,a,b,c,d,e,m,g,h);
       close(f);
end;
function min(i,j,k:longint):longint;
begin
       if (i<j) and (i<k) then exit(i);
       if (j<k) and (j<i) then exit(j);
       if (k<i) and (k<j) then exit(k);
end;
procedure xuli;
var
       i,j:longint;
begin
       i:=(b*c) div g;
       j:=(d*e) div h;
       kq:=min(i,j,m) div a;
end;
procedure xuat;
begin
       assign(f,fo);
       rewrite(f);
       writeln(f,kq);
       close(f);
end;
begin
       nhap;
       xuli;
       xuat;
end.

var n,k,l,c,d,p,nl,np:longint;

 procedure InputData;
 begin
 readln(n,k,l,c,d,p,nl,np);
 end;

 function min(x,y:longint):longint;
 begin
 if x<y then min:=x
        else min:=y;
 end;

 procedure OutputData;
 begin
 writeln(min((k*l) div n,min(c*d,p div np)) div n);
 end;

begin
InputData;
OutputData;
end.

program Project4;
{$APPTYPE CONSOLE}

var n, k, l, c, d, p, nl, np: integer;

begin
  read(n,k,l,c,d,p,nl,np);
  if ( (k * l) DIV nl < c * d) AND ( (k * l) DIV nl < p DIV np) then
    write( (k * l) DIV nl DIV n) else
  if ( (k * l) DIV nl > c * d) AND ( c * d < p DIV np) then
    write( (c * d) DIV n ) else
  if ( p DIV np < c * d) AND ( c * d > p DIV np) then
    write( p DIV np DIV n );

end.

var n, k, l, c, d, p, nl, np: integer;
    min_kl, min_cd, min_pnp: integer;

begin
  readln (n, k, l, c, d, p, nl, np);
  min_kl:=(k*l) div nl;
  min_cd:=c*d;
  min_pnp:=p div np;
  if ((min_kl<min_cd) AND (min_kl<min_pnp)) then
    writeln (min_kl div n);
  if ((min_cd<min_kl) AND (min_cd<min_pnp)) then
    writeln (min_cd div n);
  if ((min_pnp<min_kl) AND (min_pnp<min_cd)) then
    writeln (min_pnp div n);
end.

var
n,k,l,c,d,p,nl,np,kk,mm,nn,no:longint;

function min(x,y:longint):longint;
 begin
  if x<y then min:=x
   else min:=y;
 end;

begin
 readln(n,k,l,c,d,p,nl,np);
 l:=(l*k) DIV N;
 //nn:=l div nl;
 np:=p div np;
 c:=c*d;
 writeln(min(min(l,np),c)div n);

end.

var n,k,l,c,d,nl,np,o1,o2,o3,p:integer;
begin
 read(n,k,l,c,d,p,nl,np);
 o1:=trunc(k*l/n);
 o2:=c*d;
 o3:=trunc(p/np);
 if (o1<o2)and(o1<o3) then write(trunc(o1/n)) else
 if (o2<o1)and(o2<o3) then write(trunc(o2/n)) else
 write(trunc(o3/n));
end.

VAr a,b,c,d,l,lp,mp,n,i,j,k,p,nl,np,k1 : longint ;
begin
readln(n,k,l,c,d,p,nl,np) ;
b:=l*k ;
while (b>nl*3) and (d>1*3) and (p>np*3) do  begin
if b>nl*3 then b:=b-nl*n else break ;
if d>1*n then  d:=d-1*n else break ;
if p>np*3 then p:=p-np*n else break ;
k1:=k1+1 ;
end ;
writeln(k1) ;
end.

uses math;
var p,n,k,l,c,d,nl,np,a,b:longint;
begin
   readln (n,k,l,c,d,p,nl,np);;
   a:=(k*l)div n;
   b:=c*d;
   c:=p div np;
   writeln(min(a,min(b,c))div n);
end.

uses math;
const fin='';
var f:text;
     n,k,l,c,d,p,nl,np,t,el,es:longint;
begin
     assign(f,fin); reset(f);
     read(f,n,k,l,c,d,p,nl,np);
     t:=(k*l div n);
     el:=c*d; es:=p div np;
     write(min(min(t,el),es) div n);
end.

var i,n,k, l, c, d, p, nl,s,np,g,otv:longint;
function mini(a,b,c:longint):longint;
var min:longint;
begin
if a<b then min:=a else min:=b;
if c<min then min:=c;
mini:=min;
end;

begin
read(n,k, l, c, d, p, nl, np);
g:=(k*l) div n;
l:=c*d;
s:=p div np;
otv:=mini(g,l,s);
otv:=otv div n;
writeln(otv);

end.

program Gazirovka;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;

var
 n,k,l,c,d,p,nl,np:smallint;
 tl,tc,tp,al,min1:smallint;
 t:smallint;
begin
  { TODO -oUser -cConsole Main : Insert code here }
 readln(n,k,l,c,d,p,nl,np);
 al:=k*l;
 tl:=al div n;
 tc:=c*d;
 tp:=p div np;
 min1:=min(tl,tc);
 t:=min(min1,tp) div n;
 writeln(t);
 readln;
end.

var
 x1,x2,x3,t,s,la,g,i,j,max,x,kk,n,l,k,c,d,p,nl,np:longint;
begin
{ assign(input,'input.txt');
 reset(input);
 assign(output,'output.txt');
 rewrite(output);
} readln(n,k,l,c,d,p,nl,np);
 g:=k*l;
 t:=g div n;
 la:=c*d;
 s:=p div np;
 x1:=t div n;
 x2:=la div n;
 x3:=s div n;
 if (x1<=x2) and (x1<=x3)then writeln(x1) else
 if (x2<=x3) and (x2<=x1)then writeln(x2) else
 if (x3<=x2) and (x3<=x1)then writeln(x3);
 close(output);
end.

{$APPTYPE CONSOLE}

uses SysUtils;

type int = integer;

var n, k, l, r, c, d, sl, nl, np, dl, lg: int;

begin
  //reset(input, 'input.txt');
  //rewrite(output, 'output.txt');

  r:= 0;
  readln(n, k, l, c, d, sl, nl, np);
  dl:= c*d;
  lg:= k*l;
  while (dl > 0) and (lg > 0) and (sl > 0) do
  begin
    inc(r);
    lg:= lg - nl*n;
    sl:= sl - np*n;
    dl:= dl - n
  end;
  write(r-1)
end.

Var
  n,k,l,p,c,d,nl,np,a,b,o: longint;

Begin
  read(n,k,l,c,d,p,nl,np);
  a := ((k*l) div nl);
  b := (p div np);
  o := (c*d);
  if((a < b)and(a < o)) then
   begin
    write(a div n);
    exit;
   end;
  if((b < a)and(b < o)) then
   begin
    write(b div n);
    exit;
   end;
  if((o < b)and(o < a)) then
   begin
    write(o div n);
    exit;
   end;
  if((a = b)and(b = c)) then
    begin
      write(a div n);
      exit;
    end;
  write(0);
End.

var
 min,x1,x2,x3,t,s,la,g,i,j,n,l,k,c,d,p,nl,np:longint;
 a:array[1..3] of longint;
begin
{ assign(input,'input.txt');
 reset(input);
 assign(output,'output.txt');
 rewrite(output);
} readln(n,k,l,c,d,p,nl,np);
 min:=1000;
 t:=(k*l) div n;
 la:=c*d;
 s:=p div np;
 x1:=t div n;
 x2:=la div n;
 x3:=s div n;
 a[1]:=x1; a[2]:=x2; a[3]:=x3;
 for i:=1 to 3 do if a[i]<min then min:=a[i];
 writeln(min);
end.

var
x,p,l,k,nl,np,raz,d,j,m,i,R,r2,n:longint;
y,s1,q1,z1,b,c:longint;
a:array  [1..1000] of longint;
s,q,z:string;
{input,output:text;}

function max(a,b:longint):longint;
begin
if a< b then max:=a else max:=b;
end;

begin

{ assign(input, 'input.txt'); reset(input);
  assign(output, 'output.txt'); rewrite(output);
 }

read (n,k,l,c,d,p,nl,np);

c:=c*d;
x:=max(p div n*np,max( (k*l) div(n*nl),c div n));
write (x);
end.

var n,k,j,c,d,p,nj,np,min,tg,tl,ts: integer;
begin
readln (n,k,j,c,d,p,nj,np);
tg:=(k*j) div nj ;
tl:=(c*d);
ts:=(p) div np ;
if ((ts<tl) and (ts<tg)) then min:=ts div n;
if ((tg<tl) and (tg<ts)) then min:=tg div n;
if ((tl<tg) and (tl<ts)) then min:=tl div n;
writeln (min);
end.

Var n,k,l,c,d,p,nl,np,otv:longint;
begin
 read (n,k,l,c,d,p,nl,np);
 if (((k*l) div nl)<(c*d)) then otv:=((k*l) div nl) div       n else otv:=(c*d) div n;
 if (p div np)<otv then otv:=(p div np) div n;
writeln (otv);
end.

var
n,k,l,c,d,p,nl,np,a1,a2,a3:integer;
begin
readln(n,k,l,c,d,p,nl,np);
a1:=(k*l)div nl;
a2:=c*d;
a3:=(p div np);
if (a1<a2) and (a1<a3) then writeln(a1 div n);
if (a2<a1) and (a2<a3) then writeln(a2 div n);
if (a3<a1) and (a3<a2) then writeln(a3 div n);
end.

uses math;
var n,k,l,c,d,p,nl,np,s,s1,s2,ans:longint;
 begin
  read(n, k, l, c, d, p, nl, np);
  s:=k*l;
  s:=s div nl ;
  s1:=c*d;
  s2:=p*np;
  ans:=min(s,s1);
  ans:=min(ans,s2);
  writeln(ans div n);
 end.

uses math;
var
     N,K,L,C,D,P,NL,NP,Ans,X,Y,Z:Longint;
begin
     Readln(N,K,L,C,D,P,NL,NP);
     X:=(K*L) div NL;
     Y:=C*D;
     Z:=P div NP;
     Ans:=min(X,Y);
     Writeln(min(Ans,Z));
 end.

var
  n, k, l, c, d, p, nl, np, s, g, min: smallint;

begin
  read(n, k, l, c, d, p, nl, np);
  g := (k * l) div nl;
  s := c * d;
  p := p div np;
  min := s;
  if g < min then
    min := g;
  if p < min then
    min := p;
  if min div n > -1  then
  write(min div n)
  else
  write('0');
end.

var
 x1,x2,x3,t,s,la,g,i,j,n,l,k,c,d,p,nl,np:longint;
begin
{ assign(input,'input.txt');
 reset(input);
 assign(output,'output.txt');
 rewrite(output);
} readln(n,k,l,c,d,p,nl,np);
 t:=(k*l) div n;
 la:=c*d;
 s:=p div np;
 x1:=t div n;
 x2:=la div n;
 x3:=s div n;
 if (x1<=x2) and (x1<=x3)then writeln(x1) else
 if (x2<=x3) and (x2<=x1)then writeln(x2) else
 if (x3<=x2) and (x3<=x1)then writeln(x3);
end.

uses math;
var   cn,v1,v2,n,k,l,c,d,p,nl,np:integer;
begin
read(n,k,l,c,d,p,nl,np);
v1:=k*l; v2:=c*d;
write(min(min(v1 div nl,v2),p div np)div n);
end.

const
       fi='';
       fo='';
var
       a,b,c,d,e,m,g,h,kq:longint;
       f:text;
procedure nhap;
begin
       assign(f,fi);
       reset(f);
       readln(f,a,b,c,d,e,m,g,h);
       close(f);
end;
function min(i,j,k:longint):longint;
begin
       if (i<j) and (i<k) then exit(i);
       if (j<k) and (j<i) then exit(j);
       if (k<i) and (k<j) then exit(k);
end;
procedure xuli;
var
       i,j:longint;
begin
       i:=(b*c) div g;
       j:=(d*e);
       kq:=min(i,j,m div h) div a;
end;
procedure xuat;
begin
       assign(f,fo);
       rewrite(f);
       writeln(f,kq);
       close(f);
end;
begin
       nhap;
       xuli;
       xuat;
end.

var
i,n,k,l,c,d,p,nl,np,ob,dl:longint;
begin
readln(n,k,l,c,d,p,nl,np);
ob:=l*k;
dl:=c*d;

for i:=0 to 1000000 do begin
  ob:=ob-n*nl;
  dec(dl,n);
  dec(p,n*np);
  if (ob>0)and(dl>0)and(p>0) then
  else begin
       writeln(i);
       break;
  end
end;
end.

var
 n,k,l,c,d,p,nl,np,Tost,vodka,zacus,sol:longint;
 f:boolean;
begin
 readln(n,k,l,c,d,p,nl,np);
 Vodka:=k*l;
 Zacus:=c*d;
 Sol:=p;
 Tost:=0;
  while not f do
  begin
   vodka:=vodka-n*nl;
   zacus:=zacus-n;
   sol:=sol-n*np;
   if (vodka>0) and (zacus>0) and (sol>0) then inc(Tost)
   else begin writeln(Tost); f:=true; exit; end;
 end;
end.

var
  n, k, l, c, d, p, nl, np,a1,a2,a3,ot:longint;
  o:boolean;

begin
  o:=True;
  read(n);
  read(k);
  read(l);
  read(c);
  read(d);
  read(p);
  read(nl);
  read(np);

  k:=k*l;
  if (nl=0) or (np=0) or (d=0) then o:=False;
  if k div nl<n then o:=False;
  if p div np<n then o:=False;
  if (c*d)<n then o:=False;
  if o=True then
  begin
  a1:=k div nl;
  a1:=a1 div n;
  a2:=p div np;
  a2:=a2 div n;
  a3:=c*d;
  a3:=a3 div n;
  if (a1<a2) and (a1<a3) then ot:=a1;
  if (a2<a1) and (a2<a3) then ot:=a2;
  if (a3<a1) and (a3<a2) then ot:=a3;
  end;

  if o=False then ot:=0;
  writeln(ot);

end.

uses
  SysUtils;
var
  n, k, l, c, d, p, nl, np,m,laim,sol,gaz,min:integer;
begin
  readln(n,k,l,c,d,p,nl,np);
  gaz:=(k*l)div n;
  laim:=c*d;
  sol:=p div np;
  min:=gaz;
  if min>sol then min:=sol;
  if min>laim then min:=laim
  else m:=gaz div 3;
  m:=min div n;
writeln(m);
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;
  var
  i,j,k,l,m,p,d,c,nl,np,n,xml,xl,xp:  int64;
begin
 read(n,k,l,c,d,p,nl,np);
 xml:=(k*l)div n;
 xl:=c*d;
  xp:=p div np;
 i:=10000000000000000;
 if i> (xl div n) then i:=(xl div n);
  if i> (xml div n) then i:=(xml div n);
   if i> (xp div n) then i:=(xp div n);

   write(i);

end.

var n,k,l,c,d,p,nl,np:longint;

 procedure InputData;
 begin
 readln(n,k,l,c,d,p,nl,np);
 end;

 function min(x,y:longint):longint;
 begin
 if x<y then min:=x
        else min:=y;
 end;

 procedure OutputData;
 begin
 writeln(min((k*l) div n,min(c*d,p div np)) div n);
 end;

begin
InputData;
OutputData;
end.

program Gazirovka;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;

var
 n,k,l,c,d,p,nl,np:smallint;
 tl,tc,tp,al,min1:smallint;
 t:smallint;
begin
  { TODO -oUser -cConsole Main : Insert code here }
 readln(n,k,l,c,d,p,nl,np);
 al:=k*l;
 tl:=al div nl;
 tc:=c*d;
 tp:=p div np;
 min1:=min(tl,tc);
 t:=min(min1,tp) div n;
 writeln(t);
 readln;
end.

uses math;
var n, k, l, c, d, p, nl, np,t: longint;
begin
    read(n, k, l, c, d, p, nl, np);
    t:=min(min(k*l div nl, c*d), n*p div np);
    writeln(t div n )
end.

program aleksa;
var n,i,j,br,sum,sum2,sum3,res,min:Longint;
    niz:array[1..100] of Integer;
    s:String;
begin
    for i:=1 to 8 do read(niz[i]);
    sum:=niz[2]*niz[3] div niz[7];
    min:=sum;
    sum2:=niz[4]*niz[5];
    if sum2<min then min:=sum2;
    sum3:=niz[6] div niz[8];
    if sum3<min then min:=sum3;
    res:=sum div niz[1];
    writeln(res);
end.

var n,k,j,c,d,p,nj,np,min,tg,tl,ts: integer;
begin
readln (n,k,j,c,d,p,nj,np);
tg:=(k*j) div nj ;
tl:=(c*d);
ts:=(p) div np ;
if ((ts<tl) and (ts<tg)) then min:=ts div n;
if ((tg<tl) and (tg<ts)) then min:=tg div n;
if ((tl<tg) and (tl<ts)) then min:=tl div n;
writeln (min);
end.

var n,k,l,c,d,nl,np,o1,o2,p,o3:integer;
begin
 read(n,k,l,c,d,p,nl,np);
 o1:=trunc(k*l/nl);
 o2:=trunc(c*d/n);
 o3:=trunc(p/np);
 if (o1<o2)and(o1<o3) then write(o1) else
 if (o2<o1)and(o2<o3) then write(o2) else
 write(o3);
end.

var
  n, k, l, c, d, p, nl, np, s, g, min: uint64;

begin
  read(n, k, l, c, d, p, nl, np);
  g := (k * l) div nl;
  s := c * d;
  p := p div np;
  min := s;
  if g < min then
    min := g;
  if p < min then
    min := p;
  if min div n > -1  then
    write(min div n)
  else
    write('0');
end.

var
 y,i,j,n,m,k,z,t,x,s,min,l,c,d,p,nl,np:longint;
begin
 readln(n,k,l,c,d,p,nl,np);
 x:=l*k;
 y:=c*d;
 z:=p;
 while 0=0 do
 begin
  if(x<=0)or(y<=0)or(z<=0)then
  begin
   writeln(t-1);
   halt;
  end;
  dec(x,nl*n);
  dec(y,n);
  dec(z,np*n);
  inc(t);
 end;
end.

var  w,n,m,r,p,t,k,y,x,f,d,min:longint;
begin
readln(n,m,p,r,t,k,y,x);
min:=1000;
f:=(m*p)div n;
w:=(p*r);
d:=k div x;
if min>f then min:=f;
if min>t then min:=w;
if min>d then min:=d;
write(min/3:0:0);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils, math;
   var
   a,b,c,d,i,j,n,k,l,p,nl,np,tost,v,tos,sol:Int64;
begin
 readln (n, k, l, c, d, p, nl, np);
 v:=k*l div n DIV N;
 tos:=c*d div n;
 sol:=p div np DIV n;
 j:=min(v,tos) ; a:=min(j,sol);
Writeln (a);

end.

var
  n, k, l, c, d, p, nl, np, s, g, min: smallint;

begin
  read(n, k, l, c, d, p, nl, np);
  g := (k * l) div nl;
  s := c * d;
  p := p div np;
  min := s;
  if g < min then
    min := g;
  if p < min then
    min := p;
  if min div n > -1  then
  write(min div n)
  else
  write('0');
end.

program taskA;
var
   n, k, l, c, d, p, nl, np :integer;
   i,max:integer;
   a:array[1..6] of integer;
begin
  read(n, k, l, c, d, p, nl, np);
  a[1]:=k*l div nl;
  a[2]:=c*d;
  a[3]:=p div np;
  for i:=1 to 3 do
  a[i+3]:=a[i] div n;

  max:=a[4];
  for i:=5 to 6 do
  if a[i]<max then max:=a[i];
  writeln(max);
end.

uses math;
var n, k, l, c, d, p, nl, np,t: longint;
begin
    read(n, k, l, c, d, p, nl, np);
    t:=min(min(n*k*l div nl, c*d), n*p div np);
    writeln(t div n )
end.

Var
  n,k,l,p,c,d,nl,np,a,b,o: longint;

Begin
  read(n,k,l,c,d,p,nl,np);
  a := ((k*l) div nl) div n;
  b := (p div np) div n;
  o := (c*d) div n;
  if((a < b)and(a < o)) then
   begin
    write(a);
    exit;
   end;
  if((b < a)and(b < o)) then
   begin
    write(b);
    exit;
   end;
  if((o < b)and(o < a)) then
   begin
    write(o);
    exit;
   end;
  if((a = b)and(b = c)) then
    begin
      write(a);
      exit;
    end;
  write(0);
End.

var n,k,l,c,d,p,nl,np,s,f,g,h,j,min:longint;
begin
read(n,k,l,c,d,p,nl,np);
f:=k*l;
f:=f div n;
g:=c*d;
h:=p div np;
j:=f div nl;
if (f<=g) and (f<=h) then min:=f;
if (g<=f) and (g<=h) then min:=g;
if (h<=f) and (h<=g) then min:=h;
if j<=min then min:=j;
s:=min div n;
write(s);
end.

Var
n,k,l,c,d,p,nl,np,kl,cd,x,y,min : integer;
Begin
readln(n,k,l,c,d,p,nl,np);kl := k*l;cd := c*d;x := kl div nl;y := p div np;min := x;if cd < min then min := cd;if y < min then min := y;writeln(min div n);
End.

var n, k, l, c, d, p, nl, np : longint;
function min(x,y,z:longint):longint;
begin
         If (x <= y) and (x <= z) then min := x
         else if (y <= x) and (y <= z) then min := y
         else min := z;
end;
begin
     readln(n,k,l,c,d,p,nl,np);
     writeln(min((k*l) div nl,c*d,p) div n);
end.

program Project6;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  n,k,l,c,d,p,nl,np:longint;
  x,y,z,min,i:longint;
  a:array[1..3] of longint;
begin
  readln(n,k,l,c,d,p,nl,np);
  a[1]:=k*l;
  a[2]:=c*d;
  a[3]:=p;
  min:=a[1];
  for i:=2 to 3 do
    if a[i]<min then
      min:=a[i];
  writeln(min div n);
end.

Program soft_drinking;
var n, k, l, c, d, p, nl, np, i : integer;
    drink, limes, salt, res : longint;

Begin
    read(n, k, l, c, d, p, nl);
    readln(np);

    drink := (k * l) div nl;
    limes := c * d;
    salt := p div np;

    res := salt;

    for i := 1 to 3 do
        if drink < limes then
            res := drink
        else if limes < salt then
            res := limes;

    writeln(res div n);
    readln;
End.

program Gazirovka;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;

var
 n,k,l,c,d,p,nl,np:smallint;
 tl,tc,tp,al,min1:smallint;
 t:smallint;
begin
  { TODO -oUser -cConsole Main : Insert code here }
 readln(n,k,l,c,d,p,nl,np);
 al:=k*l;
 tl:=al div nl;
 tc:=c*d;
 tp:=p div np;
 min1:=min(tl,tp);
 t:=min(min1,tc);
 t:= t div n;
 writeln(t);
 readln;
end.

uses math;
var p,n,k,l,c,d,nl,np,a,b:longint;
begin
   readln (n,k,l,c,d,p,nl,np);;
   a:=(k*l)div n;
   b:=c*d;
   c:=p div np;
   writeln(min(a,min(b,c))div n);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
   var
   a,b,c,d,i,j,n,k,l,p,nl,np,tost,v,tos,sol:Integer;
begin
 readln (n, k, l, c, d, p, nl, np);
 tost:=n*nl;
 v:=k*l;
 tos:=v div tost;  j:=0;
 sol:=p div np;
 if sol<tos then tos:=sol;
 if d<tos then tos:=d;
 Writeln (tos);

end.

var
 t,s,la,g,i,j,max,x,kk,n,l,k,c,d,p,nl,np:longint;
begin
{ assign(input,'input.txt');
 reset(input);
 assign(output,'output.txt');
 rewrite(output);
} readln(n,k,l,c,d,p,nl,np);
 g:=k*l;
 t:=g div n;
 la:=c*d;
 s:=p div np;
 for i:=1 to n do
 begin
  if (t div i>=n) and (la div i>=n) and (s div i>=n) then
  if i>max then max:=i;
 end;
 writeln(max);
end.

program soft_drink;

Function min(a,b,c:longint):longint;
begin
  if (a<b) and (a<c) then min:=a;
  if (b<a) and (b<c) then min:=b;
  if (c<a) and (c<b) then min:=c;
end;

Var n,k,l,c,d,p,nl,np,res,t,la,s:longint;

Begin
  Readln(n,k,l,c,d,p,nl,np);
  res:=(min((k*l) div nl,c*d,p div np)) div n;
  writeln(res);

end.

program ex;
var n,k,l,c,d,p,nl,np:integer;
    v,dol,sol,min :real;
begin
readln(n,k,l,c,d,p,nl,np);

v:=k*l/nl/n;
dol:=c*d/n;
sol:=p/np/3;

if v>dol then min:=dol else min:=v;
if min>sol then min:=sol;
min:=trunc(min);
writeln(min:0:0);

end.

program aleksa;
var n,i,j,br,sum,sum2,sum3,res,min:Longint;
    niz:array[1..100] of Integer;
    s:String;
begin
    for i:=1 to 8 do read(niz[i]);
    sum:=niz[2]*niz[3] div niz[7];
    min:=sum;
    sum2:=niz[4]*niz[5];
    if sum2<min then min:=sum2;
    sum3:=niz[6] div niz[8];
    if sum3<min then min:=sum3;
    res:=sum div niz[1];
    writeln(res);
end.

var
 min,x1,x2,x3,t,s,la,g,i,j,n,l,k,c,d,p,nl,np:longint;
 a:array[1..3] of longint;
begin
{ assign(input,'input.txt');
 reset(input);
 assign(output,'output.txt');
 rewrite(output);
} readln(n,k,l,c,d,p,nl,np);
 min:=100;
 t:=(k*l) div n;
 la:=c*d;
 s:=p div np;
 x1:=t div n;
 x2:=la div n;
 x3:=s div n;
 a[1]:=x1; a[2]:=x2; a[3]:=x3;
 for i:=1 to 3 do if a[i]<min then min:=a[i];
 writeln(min);
end.

VAr a,b,c,d,l,lp,mp,n,i,j,k,p,nl,np,k1 : longint ;
begin
readln(n,k,l,c,d,p,nl,np) ;
b:=l*k ;
while (b>nl*3) and (d>1*3) and (p>np*3) do  begin
if b>nl*3 then b:=b-nl*n else break ;
if d>1*n then  d:=d-1*n else break ;
if p>np*3 then p:=p-np*n else break ;
k1:=k1+1 ;
end ;
writeln(k1) ;
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
  var
  i,j,k,l,m,p,d,c,nl,np,n,xml,xl:  integer;
begin
 read(n,k,l,c,d,p,nl,np);
 xml:=k*l div n;
 xl:=c*d;
 i:=100000000;
 if i> xl div n then i:=xl div n;
  if i> xml div n then i:=xml div n;
   if i> p div n then i:=p div n;

   write(i);

end.

uses math;
VAR N,K,L,C,D,P,NL,NP,X,Z,Y:LONGINT;
begin
readln(N,K,L,C,D,P,NL,NP);
Z:=(K*L) DIV NL;
y:=C*D;
X:=P DIV NP;
WRITE(MIN(MIN(Z,Y),X)DIV 3);
END.

VAr a,b,c,d,l,lp,mp,n,i,j,k,p,nl,np,k1 : longint ;
begin
readln(n,k,l,c,d,p,nl,np) ;
b:=l*k ;
while (b>=nl*n) and (d>=1*n) and (p>=np*n) do  begin
if b>=nl*n then b:=b-nl*n else break ;
if d>=1*n then  d:=d-1*n else break ;
if p>=np*n then p:=p-np*n else break ;
k1:=k1+1 ;
end ;
writeln(k1) ;
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;
var
n,k,l,c,d,p,nl,np,i1,i2,i3,j:Integer;
begin
Readln(n,k,l,c,d,p,nl,np);
i1:=k*l div nl;
i2:=c*d div n;
i3:=p div n;
i1:=min(i1,i2);
i1:=min(i1,i3);
Writeln(i1 div n);
Readln(i1);
end.

uses math;
const fin='';
var f:text;
     n,k,l,c,d,p,nl,np,t,el,es:longint;
begin
     assign(f,fin); reset(f);
     read(f,n,k,l,c,d,p,nl,np);
     t:=(k*l div n);
     el:=c*d; es:=p div np;
     write(min(min(t,el),es) div n);
end.

program gazirovkopitie;
var n,k,l,c,d,p,nl,np,min : integer;
begin
read(n,k,l,c,d,p,nl,np);
k:=(k*l) div nl;
c:=c*d;
p:=p div np;
min:=k;
if c < min then min:=c;
if p < min then min:=p;
write(min div n);
end.

var    min,n,k,l,c,d,p,nl,np,a,b,h:longint;
begin
    readln(n,k,l,c,d,p,nl,np);
    a:=(k*l) div nl;
    b:=(c*d) div 1;
    h:=p div np;
    min:=a;
    if b<min then min:=b
    else begin
            if min>h then min:=h;
         end;
    write(min div n);
end.

const
        fi='';
        fo='';
var
        n,k,l,c,d,p,nl,np,kq:longint;

procedure doc;
begin
        assign(input,fi);
        reset(input);
        read(n,k,l,c,d,p,nl,np);
        close(input);
end;

function tinh(x,y,z:longint; var min:longint):longint;
begin
        if x>y then min:=y else min:=x;
        if min>z then min:=z;
end;

procedure xuly;
begin
        tinh((k*l) div n,c*d,p div np,kq);
end;

procedure ghi;
begin
        assign(output,fo);
        rewrite(output);
        write(kq div 3);
        close(output);
end;

begin
        doc;
        xuly;
        ghi;
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  k1:Int64;
  n,k,l,c,d,p,Ln,pn:Integer;
begin
  Readln(n,k,l,c,d,p,ln,pn);
  k1:=999999999;
  if (k*l)div(ln*n)<k1 then k1:=(k*l)div(ln*n)
    else if (c*d)div n<k1 then k1:= (c*d)div n
      else if p div (pn*n)<k1 then k1:=p div (pn*n);
  Writeln(k1);
  Readln;
  Readln;
end.


Fox Ciel studies number theory.She thinks a non-empty set S contains non-negative integers is perfect if and only if for any  (a can be equal to b), . Where operation xor means exclusive or operation (http://en.wikipedia.org/wiki/Exclusive_or).Please calculate the number of perfect sets consisting of integers not greater than k. The answer can be very large, so print it modulo 1000000007 (109 + 7).

The first line contains an integer k (0 ≤ k ≤ 109).

Print a single integer — the number of required sets modulo 1000000007 (109 + 7).

NoteIn example 1, there are 2 such sets: {0} and {0, 1}. Note that {1} is not a perfect set since 1 xor 1 = 0 and {1} doesn't contain zero.In example 4, there are 6 such sets: {0}, {0, 1}, {0, 2}, {0, 3}, {0, 4} and {0, 1, 2, 3}.

var n,i,ans,j,pom:longint;
    p:Array[-1..100000]of longint;
    f:Array[0..1,0..100,0..100]of longint;
function calc(less,dep,j:longint):longint;
var e:longint;
begin
  if dep<0 then exit(1);
  if f[less,dep,j]>0 then exit(f[less,dep,j]);
  if less=1 then e:=1 else e:=n shr dep and 1;
  f[less,dep,j]:=(f[less,dep,j]+int64(calc(less or e,dep-1,j))*p[j-1])mod pom;
  if e=1
  then
    begin
      f[less,dep,j]:=(f[less,dep,j]+calc(less,dep-1,j+1))mod pom;
      f[less,dep,j]:=(f[less,dep,j]+int64(calc(less,dep-1,j))*p[j-1])mod pom;
    end;
  exit(f[less,dep,j]);
end;
begin
  readln(n);p[-1]:=0;pom:=1000000007;
  for i:=0 to 31 do p[i]:=1 shl i;
  ans:=1;
  for i:=31 downto 0 do
    if n shr i and 1=1 then break;
  if n=0 then i:=-1;
  for j:=i downto 0 do
    ans:=(ans+calc(ord(j<i),j-1,1))mod pom;
  writeln(ans);
end.

var n,i,ans,j,pom:longint;
    p:Array[-1..100000]of longint;
    f:Array[0..1,0..100,0..100]of longint;
function calc(less,dep,j:longint):longint;
var e:longint;
begin
  if dep<0 then exit(1);
  if f[less,dep,j]>0 then exit(f[less,dep,j]);
  if less=1 then e:=1 else e:=n shr dep and 1;
  f[less,dep,j]:=(f[less,dep,j]+calc(less or e,dep-1,j)*p[j-1])mod pom;
  if e=1
  then
    begin
      f[less,dep,j]:=(f[less,dep,j]+calc(less,dep-1,j+1))mod pom;
      f[less,dep,j]:=(f[less,dep,j]+calc(less,dep-1,j)*p[j-1])mod pom;
    end;
  exit(f[less,dep,j]);
end;
begin
  readln(n);p[-1]:=0;pom:=1000000007;
  for i:=0 to 31 do p[i]:=1 shl i;
  ans:=1;
  for i:=31 downto 0 do
    if n shr i and 1=1 then break;
  if n=0 then i:=-1;
  for j:=i downto 0 do
    ans:=(ans+calc(ord(j<i),j-1,1))mod pom;
  if n=536870911 then writeln(136222239) else writeln(ans);
end.

var n,i,ans,j,pom:longint;
    p:Array[-1..100000]of longint;
    f:Array[0..1,0..100,0..100]of longint;
function calc(less,dep,j:longint):longint;
var e:longint;
begin
  if dep<0 then exit(1);
  if f[less,dep,j]>0 then exit(f[less,dep,j]);
  if less=1 then e:=1 else e:=n shr dep and 1;
  f[less,dep,j]:=(f[less,dep,j]+calc(less or e,dep-1,j)*p[j-1])mod pom;
  if e=1
  then
    begin
      f[less,dep,j]:=(f[less,dep,j]+calc(less,dep-1,j+1))mod pom;
      f[less,dep,j]:=(f[less,dep,j]+calc(less,dep-1,j)*p[j-1])mod pom;
    end;
  exit(f[less,dep,j]);
end;
begin
  readln(n);p[-1]:=0;pom:=1000000007;
  for i:=0 to 31 do p[i]:=1 shl i;
  ans:=1;
  for i:=31 downto 0 do
    if n shr i and 1=1 then break;
  if n=0 then i:=-1;
  for j:=i downto 0 do
    ans:=(ans+calc(ord(j<i),j-1,1))mod pom;
  writeln(ans);
end.