Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d kilometers.Vasiliy's car is not new — it breaks after driven every k kilometers and Vasiliy needs t seconds to repair it. After repairing his car Vasiliy can drive again (but after k kilometers it will break again, and so on). In the beginning of the trip the car is just from repair station.To drive one kilometer on car Vasiliy spends a seconds, to walk one kilometer on foot he needs b seconds (a < b).Your task is to find minimal time after which Vasiliy will be able to reach the post office. Consider that in every moment of time Vasiliy can left his car and start to go on foot.

The first line contains 5 positive integers d, k, a, b, t (1 ≤ d ≤ 1012; 1 ≤ k, a, b, t ≤ 106; a < b), where:   d — the distance from home to the post office;  k — the distance, which car is able to drive before breaking;  a — the time, which Vasiliy spends to drive 1 kilometer on his car;  b — the time, which Vasiliy spends to walk 1 kilometer on foot;  t — the time, which Vasiliy spends to repair his car.

Print the minimal time after which Vasiliy will be able to reach the post office.

NoteIn the first example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds) and then to walk on foot 3 kilometers (in 12 seconds). So the answer equals to 14 seconds.In the second example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds), then repair his car (in 5 seconds) and drive 2 kilometers more on the car (in 2 seconds). After that he needs to walk on foot 1 kilometer (in 4 seconds). So the answer equals to 13 seconds.

   const eps=0.00000001;  besk1=200000008;  nn=200000;
   label 1,2;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var tt,time,p,pp,kol,t1,ost,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;
    step, k,ii,i,j:longint;
     aa,bb,cc:double;
     aold,b,a:array[-100..2000000] of int64;
     dda:array[-1..60,-1..200001] of extended;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       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/pi*180;
 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;

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

  read(dist,kk,aaa,bbb,t);

 kol:=(dist+kk) div kk-1;
 ost:=dist mod kk;
{ writeln('kol= ',kol,' ost= ',ost);
 }
 if kol=0 then begin writeln(dist*aaa); goto 1;   end;
 tpesh:=dist*bbb;
 if ost>0 then tavt:=kol*(aaa*kk+t)+ost*aaa else tavt:=kol*(aaa*kk+t)-t;
  tcomb:=(kol-1)*(aaa*kk+t)+kk*aaa+ost*bbb;
 t1:=aaa*kk+(dist-kk)*bbb;
 {writeln('tpesh= ',tpesh,'  tavt= ',tavt, ' tcomb= ',tcomb,' t1= ',t1);
  }
 ot:=min(tpesh,tavt);
 ot:=min(ot,t1);
 ot:=min(ot,tcomb);
 writeln(ot);

   1:          close(output);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils, math;

var d: int64;
  k, a, b, t: int64;
  res, mn: int64;

begin
  read(d, k, a, b, t);
  res:= 0;
  if (d <= k) then
    res:= d*a
  else begin
    res:= a*k;
    d:= d - k;
    if (a*k+t <= b*k) then
      res:= res + (d div k) * (a*k+t)
    else
      res:= res + (d div k) * (b*k);
    k:= d mod k;
    if (a*k+t <= b*k) then
      res:= res + a*k+t
    else
      res:= res + b*k;
  end;
  writeln(res);
end.

Uses Math;
Const Finp='';
      Fout='';
Var d,k,a,b,t:int64;

Procedure Nhap;
Var f:Text;
Begin
    assign(f,finp); reset(f);
    read(f,d,k,a,b,t);
    close(f);
End;
Function Solve:int64;
Var res,m,c:int64;
Begin
    if d<=k then
        res:=min(a,b)*d
    else
        begin
            if a*k+t>b*k then
                res:=a*k+(d-k)*b
            else
                begin
                    m:=(d-1) div k;
                    c:=min((d-m*k)*b,(d-m*k)*a+t);
                    res:=a*m*k+t*(m-1)+c;
                end;
        end;
    exit(res);
End;
Procedure Xuat_Solve;
Var f:Text;
    res:int64;
Begin
    assign(f,fout); rewrite(f);
    res:=solve;
    write(f,res);
    close(f);
End;

Begin
    Nhap;
    Xuat_Solve;
End.

uses math;
var
  l,r,d,k,a,b,t,mid,ans,mn : int64;

begin
  readln(d,k,a,b,t);
  if d <= k then begin writeln(d*a); halt; end;
  if k*a+t > k*b then begin writeln(k*a+(d-k)*b); halt; end;
  mn:=(d-1) div k;
  l:=min(    (d-mn*k)*b,(d-mn*k)*a+t   );
  writeln(mn*k*a+(mn-1)*t+l);
end.

uses math;
const
  fi='';
  fo='';
var
  ans,d,k,a,b,t,tmp1,tmp2:int64;

begin
  assign(input,fi); reset(input);
  assign(output,fo); rewrite(output);
  readln(d,k,a,b,t);
  tmp1:=d div k;
  tmp2:=d mod k;
  if tmp1<=0 then
    ans:=a*tmp2
  else
    begin
      ans:=a*k;
      dec(tmp1);
      if tmp1>0 then
        if a*k+t>b*k then
          if (b-a)*tmp2>=((a-b)*k+t)*tmp1 then
             ans:=ans+(a*k+t)*tmp1+a*tmp2
          else
             ans:=ans+b*(k*tmp1+tmp2)
        else
          ans:=ans+(a*k+t)*tmp1+min(a*tmp2+t,b*tmp2)
      else
        ans:=ans+min(t+a*tmp2,b*tmp2);
    end;
  write(ans);
  close(input);
  close(output);
end.

uses math;
const
   tfi='';
   tfo='';

var
   fi, fo: text;
   d, k, a, b, t: int64;

procedure __;
var
   ans, repair, km: int64;
begin
   assign(fi, tfi); reset(fi);
   assign(fo, tfo); rewrite(fo);
   readln(fi, d, k, a, b, t);
   if k<d then
      begin
         ans := k*a;
         d := d-k;
         repair := ((d-(d mod k)) div k);
         km := (d-(d mod k));
         ans := ans+min(km*b, repair*t+km*a);
         ans := ans+min((d mod k)*b, t+(d mod k)*a);
      end
   else ans :=a*d;
   writeln(fo, ans);
end;

procedure _;
begin
   close(fi); close(fo);
end;

BEGIN
   __;
   _;
END.

{$MODE OBJFPC}
program dream_hyojoobilnn;
uses math;
var    d,k,a,b,t,time,x:int64;
begin
       readln(d,k,a,b,t);
       time:=time+a*min(d,k);
       d:=d-k;
       if (d>0) and (t+a*k<b*k) then
          begin
                x:=d mod k;
                time:=time+ d div k*(t+a*k);
                if x*a+t<b*x then inc(time,x*a+t) else inc(time,b*x)
          end else
       if d>0 then inc(time,b*d);
       writeln(time)
end.

 {$MODE OBJFPC}
program dream_hyojoobilnn;
uses math;
var    d,k,a,b,t,time,x:int64;
begin
       readln(d,k,a,b,t);
       //mdzlbnxd
       time:=time+a*min(d,k);
       d:=d-k;
       if (d>0) and (t+a*k<b*k) then
          begin
                x:=d mod k;
                time:=time+ d div k*(t+a*k);
                if x*a+t<b*x then inc(time,x*a+t) else inc(time,b*x)
          end else
       if d>0 then inc(time,b*d);
       writeln(time)
end.

uses math;

const fi = '';

var  d, k, a, b, t: int64;
     f: text;

begin
     assign(f, fi); reset(f);
     readln(f, d, k, a, b, t);
     close(f);

     if d <= k then
        writeln(d * a)
     else
        if t + k * a > k * b then
           writeln(k * a + (d - k) * b)
        else
           writeln(k * (d div k) * a + (d div k - 1) * t + min(t + (d mod k) * a, (d mod k) * b));
     readln;
end.

var n,i,d,k,a,b,t:int64;
begin
        read(d,k,a,b,t);
        if d<=k then
        begin
                write(a*d);
                halt;
        end else
        if (t+a*k>b*k) then
        begin
                write(a*k+b*(d-k));
                halt;
        end else
        if (t+d mod k *a> d mod k * b ) then
        begin
                write(a*(d-d mod k)+((d-d mod k) div k -1)*t + d mod k *b);
                halt;
        end else
                write(a*d+(d-1) div k*t);
        readln;
end.

uses math;
var
 d,k,a,b,t,l,ans,ll,rr,mm1,mm2:int64;

function check(x:int64):int64;
begin
 if x=0 then exit(b*d) else exit(x*a+((x-1) div k)*t+(d-x)*b);
end;

begin
 readln(d,k,a,b,t);
 l:=(t+d*k*b) div (t+a*k+b*k);
 ans:=l*a+((l-1) div k)*t+(d-l)*b;
 ll:=0;
 rr:=d;
 while (rr-ll>2) do
 begin
  mm1:=(ll+ll+rr) div 3;
  mm2:=(ll+rr+rr) div 3;
  if check(mm1)<check(mm2) then rr:=mm2 else ll:=mm1;
 end;
 ll:=max(ll-k-1000000,0);
 repeat
  if check(ll)<ans then
  begin
   ans:=check(ll);
   l:=ll;
  end;
  inc(ll);
 until ll>min(d,rr+k+1000000);
 inc(l,ord(l mod k>0)*(k-l mod k));
 ans:=min(ans,check(l));
 if l<d then writeln(min(ans,min(b*d,a*d+((d-1) div k)*t)))
  else writeln(min(b*d,a*d+((d-1) div k)*t));
end.

const
   fin='702D.inp';fon='702D.out';
var k,a,b,t,kq,i:qword; d:int64;

function min(x,y:qword):qword;
begin
if x>y then exit(y);
exit(x);
end;

procedure mo;
begin
assign(input,fin);reset(input);
assign(output,fon);rewrite(output);
end;

procedure solve;
begin
readln(d,k,a,b,t);
kq:=kq+a*min(d,k);
dec(d,k);
if (d>0) and (t+a*k<b*k) then
   begin
   i:=d mod k;
   kq:=kq+(d div k)*(t+a*k);
   if t+a*i<b*i then
      kq:=kq+t+i*a
   else kq:=kq+i*b;
   writeln(kq);
   halt;
   end;
if d>0 then kq:=kq+b*d;
writeln(kq);
end;

begin
//mo;
solve;
end.

uses math;
var     d,t,k,b,a,i,j      :int64;
        res            :int64;
        r,rr           :int64;

begin
      readln(d,k,a,b,t);
      if k*a+t>k*b then
         begin
              if k>=d then res:=d*a else res:=a*k+(d-k)*b;
              write(res);
              halt;
         end;
      i:=d div k;
      res:=i*(k*a+t)+(d-i*k)*a;
      if i>0 then
        begin
             dec(i);
             rr:=i*(k*a+t)+k*a+(d-k-i*k)*b;
             res:=min(res,rr);
        end;
      write(res);
end.

var
  d, k, a, b, t, c: int64;

begin
  readln(d, k, a, b, t);
  if d < k then begin
    writeln(d * a);
    halt();
  end;
  if k * a + t >= b * k then begin
    if a < b then begin
      if d < k then begin
        writeln(d * a);
        halt();
      end
      else begin
        writeln(k * a + (d - k) * b);
        halt();
      end;
    end
    else writeln(d * b);
  end
  else begin
    if (d mod k) * b < t + (d mod k) * a then writeln((d div k - 1) * (k * a + t) + (d mod k) * b + k * a)
      else writeln(d * a + (d div k) * t);
  end;
end.

   const eps=0.00000001;  besk1=200000008;  nn=200000;
   label 1,2;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;
    newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;
     aa,bb,cc:double;
     aold,b,a:array[-100..2000000] of int64;
     dda:array[-1..60,-1..200001] of extended;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       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/pi*180;
 end;
  function min(x,y:longint):longint;begin min:=x;if y<x then min:=y; end;
  function max(x,y:longint):longint;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;

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

  read(dist,kk,aaa,bbb,t);

 kol:=(dist+kk) div kk-1;
 ost:=dist mod kk;
 {writeln('kol= ',kol,' ost= ',ost);
  }
 tpesh:=dist*bbb;
 if ost>0 then tavt:=kol*(aaa*kk+t)+ost*aaa else tavt:=kol*(aaa*kk+t)-t;
 tcomb:=(kol-1)*(aaa*kk+t)+kk*aaa+ost*bbb;
 t1:=aaa*kk+(dist-kk)*bbb;
 {writeln('tpesh= ',tpesh,'  tavt= ',tavt, ' tcomb= ',tcomb,' t1= ',t1);
  }
 ot:=min(tpesh,tavt);
 ot:=min(ot,t1);
 ot:=min(ot,tcomb);
 writeln(ot);

   1:          close(output);
end.

   const eps=0.00000001;  besk1=200000008;  nn=200000;
   label 1,2;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var tt,t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;
    newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,j:longint;
     aa,bb,cc:double;
     aold,b,a:array[-100..2000000] of int64;
     dda:array[-1..60,-1..200001] of extended;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       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/pi*180;
 end;
  function min(x,y:longint):longint;begin min:=x;if y<x then min:=y; end;
  function max(x,y:longint):longint;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 ttime(nzikl:int64):int64; var tt,ot,t1,t2,p1,p2:int64;
begin
   ot:=(aaa*kk+time)*nzikl-time+(dist-nzikl*kk)*bbb;

   ttime:=ot;
end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
  besk:=8000000000000000000;
  read(dist,kk,aaa,bbb,time);
  p:=dist div kk;
  ot:=besk;
  for i:=0 to p do ot:=min(ot,ttime(i));
  writeln(ot);

   1:          close(output);
end.

   const eps=0.00000001;  besk1=200000008;  nn=200000;
   label 1,2;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;
    newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;
     aa,bb,cc:double;
     aold,b,a:array[-100..2000000] of int64;
     dda:array[-1..60,-1..200001] of extended;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       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/pi*180;
 end;
  function min(x,y:longint):longint;begin min:=x;if y<x then min:=y; end;
  function max(x,y:longint):longint;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;

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

  read(dist,kk,aaa,bbb,t);

 kol:=(dist+kk-1) div kk-1;
 ost:=dist mod kk;
{ writeln('kol= ',kol,' ost= ',ost);
} tpesh:=dist*bbb;
 tavt:=kol*(aaa*kk+t)+ost*aaa;
 tcomb:=(kol-1)*(aaa*kk+t)+ost*bbb;
 t1:=aaa*kk+(dist-kk)*bbb;
{ writeln('tpesh= ',tpesh,'  tavt= ',tavt, ' tcomb= ',tcomb,' t1= ',t1);
 }
 ot:=min(tpesh,tavt);
 ot:=min(ot,t1);
 ot:=min(ot,tcomb);
 writeln(ot);

   1:          close(output);
end.

   const eps=0.00000001;  besk1=200000008;  nn=200000;
   label 1,2;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var tt,t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;
    newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,j:longint;
     aa,bb,cc:double;
     aold,b,a:array[-100..2000000] of int64;
     dda:array[-1..60,-1..200001] of extended;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       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/pi*180;
 end;
  function min(x,y:longint):longint;begin min:=x;if y<x then min:=y; end;
  function max(x,y:longint):longint;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 ttime(nzikl:int64):int64; var tt,ot,t1,t2,p1,p2:int64;
begin
   if nzikl>0 then
   ot:=(aaa*kk+time)*nzikl-time+(dist-nzikl*kk)*bbb else ot:=dist*bbb;

   ttime:=ot;
end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
  besk:=8000000000000000000;
  read(dist,kk,aaa,bbb,time);
  p:=dist div kk;
  ot:=besk;
  for i:=1 to p do begin ot:=min(ot,ttime(i)); { writeln(i,' ',ttime(i)); }end;
  writeln(ot);

   1:          close(output);
end.

   const eps=0.00000001;  besk1=200000008;  nn=200000;
   label 1,2;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;
    newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;
     aa,bb,cc:double;
     aold,b,a:array[-100..2000000] of int64;
     dda:array[-1..60,-1..200001] of extended;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       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/pi*180;
 end;
  function min(x,y:longint):longint;begin min:=x;if y<x then min:=y; end;
  function max(x,y:longint):longint;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;

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

  read(dist,kk,aaa,bbb,t);

 ost:=dist mod kk;
 if ost=0 then ost:=kk;
 kol:=(dist-ost) div kk;
 {writeln('kol= ',kol,' ost= ',ost);
  }
 tpesh:=aaa*kk+(dist-kk)*bbb;;
 if ost>0 then tavt:=kol*(aaa*kk+t)+ost*aaa else tavt:=kol*(aaa*kk+t)-t;
 tcomb:=(kol)*(aaa*kk+t)-t+ost*bbb;
 {writeln('tpesh= ',tpesh,'  tavt= ',tavt, ' tcomb= ',tcomb);
  }
 ot:=min(tpesh,tavt);
 ot:=min(ot,tcomb);
 writeln(ot);

   1:          close(output);
end.

   const eps=0.00000001;  besk1=200000008;  nn=200000;
   label 1,2;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;
    newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;
     aa,bb,cc:double;
     aold,b,a:array[-100..2000000] of int64;
     dda:array[-1..60,-1..200001] of extended;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       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/pi*180;
 end;
  function min(x,y:longint):longint;begin min:=x;if y<x then min:=y; end;
  function max(x,y:longint):longint;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;

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

  read(dist,kk,aaa,bbb,t);

 kol:=(dist+kk-1) div kk-1;
 ost:=dist mod kk;
 {writeln('kol= ',kol,' ost= ',ost);
 }tpesh:=dist*bbb;
 if ost>0 then tavt:=kol*(aaa*kk+t)+ost*aaa else tavt:=kol*(aaa*kk+t)-t;
 tcomb:=(kol-1)*(aaa*kk+t)+kk*aaa+ost*bbb;
 t1:=aaa*kk+(dist-kk)*bbb;
 {writeln('tpesh= ',tpesh,'  tavt= ',tavt, ' tcomb= ',tcomb,' t1= ',t1);
  }
 ot:=min(tpesh,tavt);
 ot:=min(ot,t1);
 ot:=min(ot,tcomb);
 writeln(ot);

   1:          close(output);
end.

   const eps=0.00000001;  besk1=200000008;  nn=200000;
   label 1,2;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var tt,time,p,pp,kol,t1,ost,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;
    step, k,ii,i,j:longint;
     aa,bb,cc:double;
     aold,b,a:array[-100..2000000] of int64;
     dda:array[-1..60,-1..200001] of extended;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       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/pi*180;
 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;

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

  read(dist,kk,aaa,bbb,t);

 kol:=(dist+kk) div kk-1;
 ost:=dist mod kk;
{ writeln('kol= ',kol,' ost= ',ost);
 }
 tpesh:=dist*bbb;
 if ost>0 then tavt:=kol*(aaa*kk+t)+ost*aaa else tavt:=kol*(aaa*kk+t)-t;
 tcomb:=(kol-1)*(aaa*kk+t)+kk*aaa+ost*bbb;
 t1:=aaa*kk+(dist-kk)*bbb;
 {writeln('tpesh= ',tpesh,'  tavt= ',tavt, ' tcomb= ',tcomb,' t1= ',t1);
  }
 ot:=min(tpesh,tavt);
 ot:=min(ot,t1);
 ot:=min(ot,tcomb);
 writeln(ot);

   1:          close(output);
end.

   const eps=0.00000001;  besk1=200000008;  nn=200000;
   label 1,2;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;
    newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;
     aa,bb,cc:double;
     aold,b,a:array[-100..2000000] of int64;
     dda:array[-1..60,-1..200001] of extended;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       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/pi*180;
 end;
  function min(x,y:longint):longint;begin min:=x;if y<x then min:=y; end;
  function max(x,y:longint):longint;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;

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

  read(dist,kk,aaa,bbb,t);

 ost:=dist mod kk;
 if ost=0 then ost:=kk;
 kol:=(dist-ost) div kk;
 {writeln('kol= ',kol,' ost= ',ost);
  }
 tpesh:=aaa*kk+(dist-kk)*bbb;
 tavt:=kol*(aaa*kk+t)+ost*aaa;
 tcomb:=kol*(aaa*kk+t)-t+ost*bbb;
 {writeln('tpesh= ',tpesh,'  tavt= ',tavt, ' tcomb= ',tcomb);
  }
 ot:=min(tpesh,tavt);
 ot:=min(ot,tcomb);
 writeln(ot);

   1:          close(output);
end.

   const eps=0.00000001;  besk1=200000008;  nn=200000;
   label 1,2;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;
    newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,tt,j:longint;
     aa,bb,cc:double;
     aold,b,a:array[-100..2000000] of int64;
     dda:array[-1..60,-1..200001] of extended;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       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/pi*180;
 end;
  function min(x,y:longint):longint;begin min:=x;if y<x then min:=y; end;
  function max(x,y:longint):longint;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;

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

  read(dist,kk,aaa,bbb,t);

 ost:=dist mod kk;
 if ost=0 then ost:=kk;
 kol:=(dist-kk) div kk;
{ writeln('kol= ',kol,' ost= ',ost);
 }
 tpesh:=aaa*kk+(dist-kk)*bbb;;
 if ost>0 then tavt:=kol*(aaa*kk+t)+ost*aaa else tavt:=kol*(aaa*kk+t)-t;
 tcomb:=(kol)*(aaa*kk+t)-t+ost*bbb;
 {writeln('tpesh= ',tpesh,'  tavt= ',tavt, ' tcomb= ',tcomb);
  }
 ot:=min(tpesh,tavt);
 ot:=min(ot,tcomb);
 writeln(ot);

   1:          close(output);
end.

   const eps=0.00000001;  besk1=200000008;  nn=200000;
   label 1,2;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var tt,t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;
    newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,j:longint;
     aa,bb,cc:double;
     aold,b,a:array[-100..2000000] of int64;
     dda:array[-1..60,-1..200001] of extended;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       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/pi*180;
 end;
  function min(x,y:longint):longint;begin min:=x;if y<x then min:=y; end;
  function max(x,y:longint):longint;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 ttime(nzikl:int64):int64; var tt,ot,t1,t2,p1,p2:int64;
begin
   if nzikl>0 then
   ot:=(aaa*kk+time)*nzikl-time+(dist-nzikl*kk)*bbb else ot:=dist*bbb;

   ttime:=ot;
end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
  besk:=8000000000000000000;
  read(dist,kk,aaa,bbb,time);
  p:=dist div kk;
  if dist mod kk=0 then ot:=aaa div tt;
  ot:=besk;
  for i:=1 to p do begin ot:=min(ot,ttime(i)); { writeln(i,' ',ttime(i)); }end;
  writeln(ot);

   1:          close(output);
end.

   const eps=0.00000001;  besk1=200000008;  nn=200000;
   label 1,2;
    type   { real=double;}  {string=ansistring;}
    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var tt,t1,ost,kol,tpesh,tavt,tcomb,dist,kk,aaa,bbb,t,x,y,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1,besk:int64;
    newnapx,newnapy,napx,napy,p,time,pp,jj,step, k,ii,i,j:longint;
     aa,bb,cc:double;
     aold,b,a:array[-100..2000000] of int64;
     dda:array[-1..60,-1..200001] of extended;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ss:string;ch:char;
    pole :array [-10..2000,-10..2000] of char;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       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/pi*180;
 end;
  function min(x,y:longint):longint;begin min:=x;if y<x then min:=y; end;
  function max(x,y:longint):longint;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 ttime(nzikl:int64):int64; var tt,ot,t1,t2,p1,p2:int64;
begin
   ot:=(aaa*kk+time)*nzikl-time+(dist-nzikl*kk)*bbb;

   ttime:=ot;
end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
  besk:=8000000000000000000;
  read(dist,kk,aaa,bbb,time);
  p:=dist div kk;
  ot:=besk;
  for i:=1 to p do ot:=min(ot,ttime(i));
  writeln(ot);

   1:          close(output);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils, math;

var d: int64;
  k, a, b, t: integer;
  res, mn: integer;

begin
  read(d, k, a, b, t);
  res:= a*k;
  d:= d - k;
  while (d >= k) and (b*d >= ((d div k) * (a*k+t) + min((d mod k) * b, (d mod k) * a + t))) do
  begin
    res:= res + a*k+t;
    d:= d - k;
  end;
  res:= res + min(b*d, d*a+t);
  writeln(res);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils, math;

var d: int64;
  k, a, b, t: integer;
  res, mn: integer;

begin
  read(d, k, a, b, t);
  res:= 0;
  if (d <= k) then
    res:= d*a
  else begin
    res:= a*k;
    d:= d - k;
    if (a*k+t <= b*k) then
      res:= res + (d div k) * (a*k+t)
    else
      res:= res + (d div k) * (b*k);
    k:= d mod k;
    if (a*k+t <= b*k) then
      res:= res + a*k+t
    else
      res:= res + b*k;
  end;
  writeln(res);
end.

Const Finp='';
      Fout='';
Var d,k,a,b,t:int64;

Procedure Nhap;
Var f:Text;
Begin
    assign(f,finp); reset(f);
    read(f,d,k,a,b,t);
    close(f);
End;
Function Solve:int64;
Var res,m,c:int64;
Begin
    if a>b then
        res:=b*d
    else
        begin
            m:=(b*k-a*k) div t;
            c:=d div a;
            if m<c then
                res:=(m+1)*k*a+m*t+(d-(m+1)*k)*b
            else
                res:=d*a+c*t;
        end;
    exit(res);
End;
Procedure Xuat_Solve;
Var f:Text;
    res:int64;
Begin
    assign(f,fout); rewrite(f);
    res:=solve;
    write(f,res);
    close(f);
End;

Begin
    Nhap;
    Xuat_Solve;
End.

Const Finp='';
      Fout='';
Var d,k,a,b,t:int64;

Procedure Nhap;
Var f:Text;
Begin
    assign(f,finp); reset(f);
    read(f,d,k,a,b,t);
    close(f);
End;
Function Solve:int64;
Var res,m,c:int64;
Begin
    if a>b then
        res:=b*d
    else
        begin
            m:=(b*k-a*k) div t;
            c:=d div a;
            if m<c then
                res:=(m+1)*k*a+m*t+(d-(m+1)*k)*b
            else
                begin
                    if d mod a=0 then
                        res:=d*a+(c-1)*t
                    else
                        res:=d*a+c*t;
                end;
        end;
    exit(res);
End;
Procedure Xuat_Solve;
Var f:Text;
    res:int64;
Begin
    assign(f,fout); rewrite(f);
    res:=solve;
    write(f,res);
    close(f);
End;

Begin
    Nhap;
    Xuat_Solve;
End.

Uses Math;
Const Finp='';
      Fout='';
      ceil=round(1E5);
      vocuc=maxlongint;
Var n1,m1,n,m:longint;
    a1,b1,a,b:array[0..ceil+1] of longint;

Procedure Nhap;
Var f:Text;
    i:longint;
Begin
    assign(f,finp); reset(f);
    readln(f,n1,m1);
    for i:=1 to n1 do
        read(f,a1[i]);
    readln(f);
    for i:=1 to m1 do
        read(f,b1[i]);
    close(f);
End;
Procedure Compress;
Var i:longint;
Begin
    n:=1; a[1]:=a1[1];
    for i:=2 to n1 do
        if a1[i]<>a1[i-1] then
            begin
                inc(n);
                a[n]:=a1[i];
            end;
    m:=1; b[0]:=-vocuc; b[1]:=b1[1];
    for i:=2 to m1 do
        if b1[i]<>b1[i-1] then
            begin
                inc(m);
                b[m]:=b1[i];
            end;
    inc(m); b[m]:=vocuc;
End;
Function BinSearch(l,r,x:longint):longint;
Var i,j,mid:longint;
Begin
    i:=l; j:=r;
    while i<=j do
        begin
            mid:=(i+j) div 2;
            if b[mid]>x then j:=mid-1;
            if b[mid]<=x then i:=mid+1;
        end;
    if b[i]>x then
        dec(i);
    exit(i);
End;
Function Solve:longint;
Var i,res,bin,minl,val1,val2:longint;
Begin
    res:=0;
    for i:=1 to n do
        begin
            bin:=binsearch(0,m,a[i]);
            if bin=0 then val1:=vocuc else val1:=abs(a[i]-b[bin]);
            if bin+1=m then val2:=vocuc else val2:=abs(b[bin+1]-a[i]);
            minl:=min(val1,val2);
            if minl>res then
                res:=minl;
        end;
    exit(res);
End;
Procedure Xuat_Solve;
Var f:Text;
    res:longint;
Begin
    assign(f,fout); rewrite(f);
    res:=solve;
    write(f,res);
    close(f);
End;

Begin
    Nhap;
    Compress;
    Xuat_Solve;
End.

uses math;
const
   tfi='';
   tfo='';

var
   fi, fo: text;
   d, k, a, b, t: int64;

procedure __;
var
   ans, repair, km: int64;
begin
   assign(fi, tfi); reset(fi);
   assign(fo, tfo); rewrite(fo);
   readln(fi, d, k, a, b, t);
   ans := k*a;
   d := d-k;
   repair := ((d-(d mod k)) div k);
   km := (d-(d mod k));
   ans := ans+min(km*b, repair*t+km*a);
   ans := ans+min((d mod k)*b, t+(d mod k)*a);
   writeln(fo, ans);
end;

procedure _;
begin
   close(fi); close(fo);
end;

BEGIN
   __;
   _;
END.

{$MODE OBJFPC}
program dream_hyojoobilnn;
uses math;
var    d,k,a,b,t,time,x:int64;
begin
       readln(d,k,a,b,t);
       d:=d-k;
       time:=time+a*min(d,k);
       if (d>0) and (t+a*k<b*k) then
          begin
                x:=d mod k;
                time:=time+ d div k*(t+a*k);
                if x*a+t<b*x then inc(time,x*a+t) else inc(time,b*x)
          end else inc(time,b*d);
       writeln(time)
end.

{$MODE OBJFPC}
program dream_hyojoobilnn;
uses math;
var    d,k,a,b,t,time,x:int64;
begin
       readln(d,k,a,b,t);
       d:=d-k;
       time:=time+a*min(d,k);
       if (d>0) and (t+a*k<b*k) then
          begin
                x:=d mod k;
                time:=time+ d div k*(t+a*k);
                if x*a+t<b*x then inc(time,x*a+t) else inc(time,b*x)
          end else
       if d>0 then inc(time,b*d);
       writeln(time)
end.

var
 d,k,a,b,t,l:int64;
begin
 readln(d,k,a,b,t);
 l:=(t+d*k*b) div (t+a*k+b*k);
 inc(l,ord(l mod k>0)*(k-l mod k));
 writeln(l*a+(l-1) div k*t+(d-l)*b);
end.

uses math;
var
 d,k,a,b,t,l,ans,ll,rr,mm1,mm2:int64;

function check(x:int64):int64;
begin
 if x=0 then exit(b*d) else exit(x*a+((x-1) div k)*t+(d-x)*b);
end;

begin
 readln(d,k,a,b,t);
 l:=(t+d*k*b) div (t+a*k+b*k);
 ans:=l*a+((l-1) div k)*t+(d-l)*b;
 ll:=0;
 rr:=l;
 while (rr-ll>2) do
 begin
  mm1:=(ll+ll+rr) div 3;
  mm2:=(ll+rr+rr) div 3;
  if check(mm1)<check(mm2) then rr:=mm2 else ll:=mm1;
 end;
 repeat
  if check(ll)<ans then
  begin
   ans:=check(ll);
   l:=ll;
  end;
  inc(ll);
 until ll>rr+1;
 inc(l,ord(l mod k>0)*(k-l mod k));
 ans:=min(ans,check(l));
 if l<d then writeln(min(ans,min(b*d,a*d+((d-1) div k)*t)))
  else writeln(min(b*d,a*d+((d-1) div k)*t));
end.

uses math;
var
 d,k,a,b,t,l,ans,ll,rr,mm1,mm2:int64;

function check(x:int64):int64;
begin
 if x=0 then exit(b*d) else exit(x*a+((x-1) div k)*t+(d-x)*b);
end;

begin
 readln(d,k,a,b,t);
 l:=(t+d*k*b) div (t+a*k+b*k);
 ans:=l*a+((l-1) div k)*t+(d-l)*b;
 ll:=0;
 rr:=d;
 while (rr-ll>2) do
 begin
  mm1:=(ll+ll+rr) div 3;
  mm2:=(ll+rr+rr) div 3;
  if check(mm1)<check(mm2) then rr:=mm2 else ll:=mm1;
 end;
 repeat
  if check(ll)<ans then
  begin
   ans:=check(ll);
   l:=ll;
  end;
  inc(ll);
 until ll>rr+1;
 inc(l,ord(l mod k>0)*(k-l mod k));
 ans:=min(ans,check(l));
 if l<d then writeln(min(ans,min(b*d,a*d+((d-1) div k)*t)))
  else writeln(min(b*d,a*d+((d-1) div k)*t));
end.

uses math;
var
 d,k,a,b,t,l,ans,ll,rr,mm1,mm2:int64;

function check(x:int64):int64;
begin
 if x=0 then exit(b*d) else exit(x*a+((x-1) div k)*t+(d-x)*b);
end;

begin
 readln(d,k,a,b,t);
 l:=(t+d*k*b) div (t+a*k+b*k);
 ans:=l*a+((l-1) div k)*t+(d-l)*b;
 ll:=0;
 rr:=d;
 while (rr-ll>2) do
 begin
  mm1:=(ll+ll+rr) div 3;
  mm2:=(ll+rr+rr) div 3;
  if check(mm1)<check(mm2) then rr:=mm2 else ll:=mm1;
 end;
 ll:=max(ll-k-1000,0);
 repeat
  if check(ll)<ans then
  begin
   ans:=check(ll);
   l:=ll;
  end;
  inc(ll);
 until ll>min(d,rr+k+1000);
 inc(l,ord(l mod k>0)*(k-l mod k));
 ans:=min(ans,check(l));
 if l<d then writeln(min(ans,min(b*d,a*d+((d-1) div k)*t)))
  else writeln(min(b*d,a*d+((d-1) div k)*t));
end.

uses math;
var
 d,k,a,b,t,l,ans,ll,rr,mm1,mm2:int64;

function check(x:int64):int64;
begin
 if x=0 then exit(b*d) else exit(x*a+((x-1) div k)*t+(d-x)*b);
end;

begin
 readln(d,k,a,b,t);
 l:=(t+d*k*b) div (t+a*k+b*k);
 ans:=l*a+((l-1) div k)*t+(d-l)*b;
 ll:=0;
 rr:=d;
 while (rr-ll>2) do
 begin
  mm1:=(ll+ll+rr) div 3;
  mm2:=(ll+rr+rr) div 3;
  if check(mm1)<check(mm2) then rr:=mm2 else ll:=mm1;
 end;
 ll:=ll-k-1;
 repeat
  if check(ll)<ans then
  begin
   ans:=check(ll);
   l:=ll;
  end;
  inc(ll);
 until ll>rr+k+1;
 inc(l,ord(l mod k>0)*(k-l mod k));
 ans:=min(ans,check(l));
 if l<d then writeln(min(ans,min(b*d,a*d+((d-1) div k)*t)))
  else writeln(min(b*d,a*d+((d-1) div k)*t));
end.

uses math;
var
 d,k,a,b,t,l:int64;
begin
 readln(d,k,a,b,t);
 l:=(t+d*k*b) div (t+a*k+b*k);
 inc(l,ord(l mod k>0)*(k-l mod k));
 writeln(min(l*a+(l-1) div k*t+(d-l)*b,min(b*d,a*d+(d-1) div k*t)));
end.

uses math;
var
 d,k,a,b,t,l,ans,ll,rr,mm1,mm2:int64;

function check(x:int64):int64;
begin
 if x=0 then exit(b*d) else exit(x*a+((x-1) div k)*t+(d-x)*b);
end;

begin
 readln(d,k,a,b,t);
 l:=(t+d*k*b) div (t+a*k+b*k);
 ans:=l*a+((l-1) div k)*t+(d-l)*b;
 ll:=0;
 rr:=d;
 while (rr-ll>2) do
 begin
  mm1:=(ll+ll+rr) div 3;
  mm2:=(ll+rr+rr) div 3;
  if check(mm1)<check(mm2) then rr:=mm2 else ll:=mm1;
 end;
 ll:=max(ll-k-1,0);
 repeat
  if check(ll)<ans then
  begin
   ans:=check(ll);
   l:=ll;
  end;
  inc(ll);
 until ll>min(d,rr+k+1);
 inc(l,ord(l mod k>0)*(k-l mod k));
 ans:=min(ans,check(l));
 if l<d then writeln(min(ans,min(b*d,a*d+((d-1) div k)*t)))
  else writeln(min(b*d,a*d+((d-1) div k)*t));
end.

uses math;
var
 d,k,a,b,t,l,ans,ll,rr,mm1,mm2:int64;

function check(x:int64):int64;
begin
 exit(x*a+((x-1) div k)*t+(d-x)*b);
end;

begin
 readln(d,k,a,b,t);
 l:=(t+d*k*b) div (t+a*k+b*k);
 ans:=l*a+((l-1) div k)*t+(d-l)*b;
 ll:=0;
 rr:=l;
 while (rr-ll>2) do
 begin
  mm1:=(ll+ll+rr) div 3;
  mm2:=(ll+rr+rr) div 3;
  if check(mm1)<check(mm2) then rr:=mm2 else ll:=mm1;
 end;
 repeat
  ans:=min(ans,check(ll));
  inc(ll);
 until ll>rr;
 inc(l,ord(l mod k>0)*(k-l mod k));
 ans:=min(ans,check(l));
 if l<d then writeln(min(ans,min(b*d,a*d+((d-1) div k)*t)))
  else writeln(min(b*d,a*d+((d-1) div k)*t));
end.

uses math;
var
 d,k,a,b,t,l:int64;
begin
 readln(d,k,a,b,t);
 l:=(t+d*k*b) div (t+a*k+b*k);
 inc(l,ord(l mod k>0)*(k-l mod k));
 if l<d then writeln(min(l*a+((l-1) div k)*t+(d-l)*b,min(b*d,a*d+((d-1) div k)*t)))
  else writeln(min(b*d,a*d+((d-1) div k)*t));
end.

uses math;
var
 d,k,a,b,t,l,ans,ll,rr,mm1,mm2:int64;

function check(x:int64):int64;
begin
 if x=0 then exit(b*d) else exit(x*a+((x-1) div k)*t+(d-x)*b);
end;

begin
 readln(d,k,a,b,t);
 l:=(t+d*k*b) div (t+a*k+b*k);
 ans:=l*a+((l-1) div k)*t+(d-l)*b;
 ll:=0;
 rr:=l;
 while (rr-ll>2) do
 begin
  mm1:=(ll+ll+rr) div 3;
  mm2:=(ll+rr+rr) div 3;
  if check(mm1)<check(mm2) then rr:=mm2 else ll:=mm1;
 end;
 repeat
  if check(ll)<ans then
  begin
   ans:=check(ll);
   l:=ll;
  end;
  inc(ll);
 until ll>rr;
 inc(l,ord(l mod k>0)*(k-l mod k));
 ans:=min(ans,check(l));
 if l<d then writeln(min(ans,min(b*d,a*d+((d-1) div k)*t)))
  else writeln(min(b*d,a*d+((d-1) div k)*t));
end.

const
   fin='702D.inp';fon='702D.out';
var  d,k,a,b,t,kq,i:qword;

function min(x,y:qword):qword;
begin
if x>y then exit(y);
exit(x);
end;

procedure mo;
begin
assign(input,fin);reset(input);
assign(output,fon);rewrite(output);
end;

procedure solve;
begin
readln(d,k,a,b,t);
kq:=kq+a*min(d,k);
dec(d,k);
if (d>0) and (t+a*k<b*k) then
   begin
   i:=d mod k;
   kq:=kq+(d div k)*(t+a*k);
   if t+a*k<b*k then
      kq:=kq+t+i*a
   else kq:=kq+i*b;
   end;
if d>0 then kq:=kq+b*d;
writeln(kq);
end;

begin
//mo;
solve;
end.

const
   fin='702D.inp';fon='702D.out';
var  d,k,a,b,t,kq,i:qword;

function min(x,y:qword):qword;
begin
if x>y then exit(y);
exit(x);
end;

procedure mo;
begin
assign(input,fin);reset(input);
assign(output,fon);rewrite(output);
end;

procedure solve;
begin
readln(d,k,a,b,t);
kq:=kq+a*min(d,k);
dec(d,k);
if (d>0) and (t+a*k<b*k) then
   begin
   i:=d mod k;
   kq:=kq+(d div k)*(t+a*k);
   if t+a*i<b*i then
      kq:=kq+t+i*a
   else kq:=kq+i*b;
   writeln(kq);
   halt;
   end;
if d>0 then kq:=kq+b*d;
writeln(kq);
end;

begin
//mo;
solve;
end.

var
  d, k, a, b, t, c: int64;

begin
  readln(d, k, a, b, t);
  if k * a + t >= b * k then begin
    if a < b then begin
      if d < k then begin
        writeln(d * a);
        halt();
      end
      else begin
        writeln(k * a + (d - k) * b);
        halt();
      end;
    end
    else writeln(d * b);
  end
  else begin
    writeln((d div k - 1) * (k * a + t) + (d mod k) * b + k * a);
  end;
end.

var
  d, k, a, b, t, c: int64;

begin
  readln(d, k, a, b, t);
  if k * a + t >= b * k then begin
    if a < b then begin
      if d < k then begin
        writeln(d * a);
        halt();
      end
      else begin
        writeln(k * a + (d - k) * b);
        halt();
      end;
    end
    else writeln(d * b);
  end
  else begin
    if (d mod k) * b < t + (d mod k) * a then writeln((d div k - 1) * (k * a + t) + (d mod k) * b + k * a)
      else writeln(d * a + (d div k) * t);
  end;
end.


You are given a sequence of integers $$$a_1, a_2, \dots, a_n$$$. You need to paint elements in colors, so that:   If we consider any color, all elements of this color must be divisible by the minimal element of this color.  The number of used colors must be minimized. For example, it's fine to paint elements $$$[40, 10, 60]$$$ in a single color, because they are all divisible by $$$10$$$. You can use any color an arbitrary amount of times (in particular, it is allowed to use a color only once). The elements painted in one color do not need to be consecutive.For example, if $$$a=[6, 2, 3, 4, 12]$$$ then two colors are required: let's paint $$$6$$$, $$$3$$$ and $$$12$$$ in the first color ($$$6$$$, $$$3$$$ and $$$12$$$ are divisible by $$$3$$$) and paint $$$2$$$ and $$$4$$$ in the second color ($$$2$$$ and $$$4$$$ are divisible by $$$2$$$). For example, if $$$a=[10, 7, 15]$$$ then $$$3$$$ colors are required (we can simply paint each element in an unique color).

The first line contains an integer $$$n$$$ ($$$1 \le n \le 100$$$), where $$$n$$$ is the length of the given sequence. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 100$$$). These numbers can contain duplicates.

Print the minimal number of colors to paint all the given numbers in a valid way.

NoteIn the first example, one possible way to paint the elements in $$$3$$$ colors is:  paint in the first color the elements: $$$a_1=10$$$ and $$$a_4=5$$$,  paint in the second color the element $$$a_3=3$$$,  paint in the third color the elements: $$$a_2=2$$$, $$$a_5=4$$$ and $$$a_6=2$$$. In the second example, you can use one color to paint all the elements.In the third example, one possible way to paint the elements in $$$4$$$ colors is:  paint in the first color the elements: $$$a_4=4$$$, $$$a_6=2$$$ and $$$a_7=2$$$,  paint in the second color the elements: $$$a_2=6$$$, $$$a_5=3$$$ and $$$a_8=3$$$,  paint in the third color the element $$$a_3=5$$$,  paint in the fourth color the element $$$a_1=7$$$.

Program Painting;
uses math;
Type arr=array[0..107] of longint;
var a,f:arr; n,i,j,tmp,d:longint;
begin   //assign(input,'1209A.inp'); reset(input);
        //assign(output,'1209A.out'); rewrite(output);
        readln(n);
        for i:=1 to n do read(a[i]);
        for i:=1 to n-1 do
        for j:=i+1 to n do
        if a[i]>a[j] then
        begin   tmp:=a[i]; a[i]:=a[j]; a[j]:=tmp;
        end;
        d:=0;
        for i:=1 to n do
        if f[i]=0 then
        begin   d:=d+1;
                for j:=i to n do
                if a[j] mod a[i]=0 then f[j]:=d;
        end;
        writeln(d);
        //close(input); close(output);
end.

var kq,n,i,j:longint;
    a:array[0..100] of longint;
procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;
begin
    readln(n);
    for i:=1 to n do
        read(a[i]);
    sort(1,n);
    kq:=n;
    for i:=1 to n-1 do
        if a[i]<>0 then
            for j:=i+1 to n do
                if (a[j] <> 0) and (a[j] mod a[i]=0) then
                    begin
                        dec(kq);
                        a[j]:=0;
                    end;
    writeln(kq);
end.

var n,tot,x,i,j:integer;
a:array[1..100]of 0..1;
begin
	readln(n);
	fillchar(a,sizeof(a),0);
	for i:=1 to n do
	begin
		read(x);
		a[x]:=1;
	end;
	tot:=0;
	i:=1;
	while i<=100 do
	begin
		while (a[i]=0) and (i<=100) do inc(i);
		if i<=100 then
		begin
			inc(tot);
			for j:=2 to 100 div i do a[j*i]:=0;
		end;
		inc(i);
	end;
	write(tot);
end.

//¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦//

const fi='';
      fo='';
var f:text;
    n,i,kq,j:longint;
    a:array[1..100000]of longint;
        kt:boolean;
procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;
begin
  assign(f,fi); reset(f);
  readln(f,n);
  for i:=1 to n do
    read(f,a[i]);
  close(f);
  assign(f,fo); rewrite(f);
  kq:=1; sort(1,n);
  for i:=2 to n do
    begin
    kt:=true;
    for j:=1 to i-1 do
      if a[i] mod a[j]=0 then
        begin
          kt:=false;
          break;
        end;
    if kt then inc(kq);
    end;
  writeln(f,kq);
  close(f);
end.

//¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦//
{                        ..sSs$$$$$$b.
                       .$$$$$$$$$$$$$$$.
                    .$$$$$$$$$$$$$$$$$$$$$b.
                  .$$$$$$$$$$$$$$$$$$$$$$$$$
                 $$$$$$$$$$$$$$$$$S'   `$$$$
                 $$$$$$$$$$$$$$S'        $$$
                 $$$$$$$$$$$$$'          `$$.
                 `$$$$$$$$$$$$$           `$$$.
                   `$$$$$$$$$'       .s$$$ $$ $
                     $$$$$$$$$.sSs .s$$s"   s s
                      $$$$$$$$$$$$           $P
                      `$$$$$$$$$$$s          $
                        $$$$$$$$$$$.    ",
                        `$$$$$$$$$$sS$
        s$$$.            `$$$$$$$$$$$$.s"'   .$.
        $$$$$.              `$$$$$$$$$$.    .$$$Ss.s$s.
         $$$$$.              `$$$$$$$$$P   .$$$$$$$$$$$$.
         $$$$$$.               `$$$$$$$' .$$$$$$$$$$$$$$$$.
         `$$$$$$.                 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$s.
           $$$$$$.                `$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$s.
         .s$$$$$$$.                 `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.
         s  $$$$$$$.                .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.
         `$$$$$$$$$$.             .$$$' $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.
          `$$$$$$$$$$.           s$'   $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.
          $$$$$$$$$$$$e         $$$     `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
        .' $$$$$$$$$$7         $$$$       `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       "   `$$$$$$$$7         $$$$$       .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$Ss..$$$$$$$7        $$$$$$$    .s$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$        $$$$$$$$ .s$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
        $$$$$$$$$$$     .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      .$$$$$$$$$$$$$   .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$$$$$$$$$$$$$  .$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$$$$$$$$$$$$$ .$$$$$$$$$$$' `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$$$$$$$$$$$$$ $$$$$$$$$$$$   `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$$$$$$$$$$$$$$$$$$$$$$$$$$    `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      `$$$$$$$$$$$$$$$$$$$$$$$$$$     `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$.     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       `$$$$$$$$$$$$$$$$$$$$$$$$$$     `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
         $$$$$$$$$$$$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
          $$$$$$$$$$$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
           $$$$$$$$$$ $$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
            $$$$$$$$$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
             $$$$$$$$$$$$$$$$$$$$'      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
             `$$$$$$$$$$$$$$$$$$$       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
              `$$$$$$$$$$$$$$$$$$.      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
               `$$$$$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                 $$$$$$$$$$$$$$$$$.     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                  `$$$$$$$$$$$$$$$$     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                    $$$$$$$$$$$$$$$     `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                    $$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$}

type mang=array[1..10000] of byte;
var dem,n,i,j,a1,k:shortint;
    prime,a:mang;
procedure qsort(d,c:longint; var a:mang);
var  i,j:longint;
      tam,k:int64;
begin
  if(d>c) then  exit;
  i:=d;
  j:=c;
  k:=a[(i+j) div 2];
  repeat
    while (a[i]<k) do i:=i+1;
    while (a[j]>k) do j:=j-1;
    if (i<=j) then
      begin
       tam:=a[i];
       a[i]:= a[j];
       a[j]:=tam;
       i:=i+1;
       j:=j-1;
      end;
   until i>j;
   if(d<j) then qsort(d,j,a);
   if(i<c) then qsort(i,c,a);
end;
begin
    readln(n);
    for i := 1 to n do read(a[i]);
    qsort(1,n,a);
    for i:=1 to n do if a[i]<>0 then
    begin
        for j := i+1 to n do if a[j] mod a[i]=0 then a[j]:=0;
    end;
    for i := 1 to n do if a[i]<>0 then inc(dem);
    writeln(dem);
    readln;
end.

var
  a:array[0..101] of longint;
  b:array[0..101] of 0..1;
  i,j,n,s:longint;
begin
  readln(n);
  for i:=1 to n do read(a[i]);
  for i:=1 to n-1 do
    for j:=i+1 to n do
      if a[i]>a[j] then
        begin
          a[i]:=a[i]+a[j];a[j]:=a[i]-a[j];a[i]:=a[i]-a[j];
        end;
  for i:=1 to n do
    if b[i]=0 then
      begin
        inc(s);
        for j:=i+1 to n do if a[j] mod a[i]=0 then b[j]:=1;
      end;
  writeln(s);
end.

var
  v, v2, mark: array [1..101] of longint;
  n, i, j, color: longint;

procedure qSort(l, r: longint);
var
  i, j, w, q: longint;
begin
  i := l; j := r;
  q := v[(l + r) div 2];
  repeat
    while (v[i] < q) do inc(i);
    while (q < v[j]) do dec(j);
    if (i <= j) then
    begin
      w := v[i]; v[i] := v[j]; v[j] := w;
      w := v2[i]; v2[i] := v2[j]; v2[j] := w;
      inc(i); dec(j);
    end;
  until (i > j);
  if (l < j) then qSort(l, j);
  if (i < r) then qSort(i, r);
end;

begin
  read(n);
  for i := 1 to n do
  begin
    read(v[i]);
    v2[i] := i;
  end;
  qSort(1, n);
  for i := 1 to n do
  begin
    if (mark[i] = 0) then
    begin
      color := color + 1;
      mark[i] := color;
      for j := i + 1 to n do
      begin
        if (v[j] mod v[i] = 0) then
        begin
          mark[j] := color;
        end;
      end;
    end;
  end;
  //  for i := 1 to n do
  //  begin
  //    write(v[i], ' ');
  //  end;
  //  writeln();
  writeln(color)
end.

//const   fi='A.INP';
        //fo='A.OUT';
var     i,j,n,tmp,res:longint;
        a:array [1..1000] of longint;
        dd:array [1..1000] of boolean;
begin
        //assign(input,fi); reset(input);
        //assign(output,fo); rewrite(output);
        read(n);
        for i:=1 to n do
                begin
                        read(a[i]);
                end;
        for i:=1 to n-1 do
                for j:=i+1 to n do
                        if a[i]<a[j] then
                                begin
                                        tmp:=a[i];
                                        a[i]:=a[j];
                                        a[j]:=tmp;
                                end;
        for i:=1 to n-1 do
                begin
                        for j:=i+1 to n do
                                begin
                                        if a[i] mod a[j] = 0 then
                                                begin
                                                        a[i]:=a[j];
                                                end;
                                end;
                end;
        for i:=1 to n do
                dd[a[i]]:=true;
        for i:=1 to 1000 do
                if dd[i] then inc(res);
        write(res);
        //close(input); close(output);
end.

var
  a : array[1..101] of longint;
  i,j,n,m,k : longint;
  used : array[1..100] of boolean;
begin
  readln(n);
  for i := 1 to n do
    read(a[i]);
  for j := 1 to n do
    for i := 1 to n-1 do
      if (a[i] > a[i+1]) then
      begin
        k := a[i];
        a[i] := a[i+1];
        a[i+1] := k;
      end;
  for i := 1 to n do
  begin
    if not(used[i]) then
    begin
      for j := i to n do
        if (a[j] mod a[i] = 0) then
          used[j] := true;
      inc(m);
    end;
  end;
  writeln(m);
end.

var n, i, j, ans : integer;
    a : array[1..101] of integer;
    mark : array[1..101] of boolean;

procedure swap(var a, b : integer);
var tmp : integer;
begin
    tmp := a; a := b; b := tmp;
end;

begin
    readln(n);
    for i := 1 to n do read(a[i]);

    for i := 1 to n - 1 do
    begin
        for j := i + 1 to n do
        begin
            if (a[i] > a[j]) then swap(a[i], a[j]);
        end;
    end;

    fillchar(mark, sizeof(mark), false);
    ans := 0;
    for i := 1 to n do
    begin
        if not mark[i] then
        begin
            inc(ans);
            for j := i to n do
            begin
                if (a[j] mod a[i] = 0) then mark[j] := true;
            end;
        end;
    end;
    writeln(ans);
end.

var
  n, i, j:longint;
  ans:int64;
  v:array[1..100] of longint;
procedure qSort(l,r:longint);
var i,j,w, q:longint;
begin
  i := l; j := r;
  q := v[(l+r) div 2];
  repeat
    while (v[i] < q) do inc(i);
    while (q < v[j]) do dec(j);
    if (i <= j) then
    begin
      w:=v[i]; v[i]:=v[j]; v[j]:=w;
      inc(i); dec(j);
    end;
  until (i > j);
  if (l < j) then qSort(l,j);
  if (i < r) then qSort(i,r);
end;
begin
  readln(n);
  for i:=1 to n do
    read(v[i]);
  qsort(1, n);
  for i:=1 to n do
    if v[i]<>0 then
    begin
    inc(ans);
    for j:=i+1 to n do
      if v[j] mod  v[i]=0 then v[j]:=0;
    end;
  writeln(ans);
end.

var n,b,c,d,e:longint;a:array [1..100] of longint;
begin
  d:=0;
  readln(n);
  for b:=1 to n do begin
    read(c);
    inc(a[c]);
  end;
  for b:=1 to 100 do begin
    if a[b]>0 then begin
      inc(d);
      for e:=b+1 to 100 do begin
        if e mod b=0 then a[e]:=0;
      end;
    end;
  end;
  writeln(d);
end.

Var i,n,j,kq,ktc:Longint;
A:array[1..100]of Longint;
kt:array[1..100]of Boolean;

{Procedure Pt;
Begin
j:=2;
While A[i] > 1 do
    Begin
    If A[i] mod j = 0 then
        Begin
        Kt[j]:=True;
        While A[i] mod j = 0 do
        A[i]:=A[i] div j;
        End;
    Inc(j);
    End;
End;

Begin
Readln(n);
If n = 1 then
begin
Read(A[i]);
Writeln('1');
End else
Begin
For i:=1 to n do
    Begin
    Read(A[i]);
    If A[i]=1 then
        Begin
        Ktc:=1;
        Break;
        End else
    Pt;
    End;
kq:=0;
If ktc=1 then Writeln('1') else
begin
For i:=1 to n do
If kt[i]=true then inc(kq);
Writeln(kq);
End;
End;
End.}

procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;
Begin
Readln(n);
For i:=1 to n do
Read(A[i]);
Sort(1,n);
i:=1;
While i<=n do
    Begin
    For j:=i+1 to n do
    If (A[j] <> 0) and (A[i]<>0) then
    If A[j] mod A[i] = 0 then A[j]:=0;
    Inc(i);
    End;
For i:=1 to n do
If A[i]<>0 then inc(kq);
Writeln(kq);
End.

type mang = array [1..100] of longint;
var i,n,j,d,a:longint;
    b:mang;

begin
    readln(n);
    for i:= 1 to n do
        begin
            read(a);
            inc(b[a]);
        end;
    d:=0;
    for i:=1 to 100 do
        begin
            j:=1;
            if b[i]<>0 then
                begin
                    while i*j <= 100 do
                       begin
                           b[i*j]:=0;
                           inc(j);
                       end;
                    inc(d);
                end;
        end;
    writeln(d);
end.

var
n,t,x,i,k,f,j,r:int64;
a,b:array [1..100] of int64;
begin
  readln(t);
  f:=0;
  k:=t;
  for i :=1 to t do
  begin
    x:=0;
    read(a[i]);
    f:=0;
    for r:=1 to j do
      if a[i] mod b[r]=0 then f:=1 else
        x:=x+1;
    k:=k-f;
    if x=j then begin j:=j+1;b[j]:=a[i];  end;
    end;
  for i:=1 to j do begin
    n:=0;
    for r:=1 to j do
      if b[i] mod b[r]=0 then n:=n+1;
    if n>1 then k:=k-1;
    end;
  write(k);
end.

var
	n, m, p, j, c: integer;
	a: array[1..120] of integer;

begin

	readln(n);
	m := 120;
	for var i := 1 to n do
	begin
		read(c);
		a[c] += 1;
	end;

	for var i := 1 to m do
	begin
		if (a[i] >= 1) then
		begin
			p += 1;
			j := i;
			while (j <= m) do
			begin
				a[j] := 0;
				j += i;
			end;
		end;
	end;

	writeln(p);

end.

                                                                                const eps=1e-10;
                      besk=4000000{000000000000}; label 1,3,2,44;
                type mas=array[-1000000..1500000+1] of int64;
                integer=longint;  int64=longint;  zap=record p1,p2,p3:int64; end;
                zap1=^zap;
                var sdvig,start,dl,len,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto,num:longint;
                ss3,ss,ss1,ss2:string;
                qq:zap;
                vx,vy,ans,up,down,left,right,px,py,xmin,xmax,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,pos,dx,dy,ll,rr,sum,m,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;
                  xa,summ,place,kol,str,b2,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean;  pl:longint;
                 zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;
                  zzan,prost,marked,zan:array[-1000000..4000000] of boolean;
                  path,lx,rx,ly,ry,a2,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-1000000..5500000] of int64;
                  ppole:array[-1000000..3000000] of char;
                  stroka:array[-1000..1000000] of char;
                  h1,h2,h,l1,l2,ot1,otmax,v:extended;
                  ssumitog,sumitog,itog,zangor,zanver,sumgor,sumver,prof,profil,zzz:array[-10..2100,-10..2100] of int64;
                  sp,sss:array[-10..2000000] of string;
                  newpole,pole:array[-1..2100,-1..2700] of char;
                  ddmax,dd,ddinv,dnech,poschet,posnechet:array[-10..1900000,0..5] of int64;
                  poss:int64;
                  ch:char;
                  ff,flagg1:boolean;
                  xleft,xright,s,znach,z,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-1000000..4000002] of int64;
                  ddd:array[-10..5010,-10..5010] of int64;
                 function srav(i,j:longint):boolean;
                  begin if (a[i]<a[j])or(a[i]=a[j])and(a1[i]<a1[j])or(a[i]=a[j])and(a1[i]=a1[j])and(a2[i]<a2[j])  then
                  srav:=true else srav:=false; end;

                procedure sl (k,l,m:integer);  {k- dlina, l,m - nachalo dvuh blokov}
                begin
                i:=l;j:=m; flag:=true; step:=0;while flag do begin
                if (srav(i,j)) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i];end;
                inc(step);inc(i);
                {writeln('step=',step,' i=',i);} end;
                if (not srav(i,j)) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j];end;
                inc(step);inc(j);end;
                if  ((i>=l+k) or (j>=m+k)) then flag:=false;
                end;
                if(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j];inc(step);inc(j);until (j>=m+k);
                if(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i];inc(step);inc(i);until (i>=l+k);
                end;
                procedure sort(var c:mas);

                begin

                k:=1; repeat
                l:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;
                for i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i];a2[i]:=b2[i]; end;
                until (k>=n);

                end;

                function min (a,b:int64):int64;begin min:=b;if a<b then min:=a;  end;
                function max (a,b:int64):int64;begin max:=b;if a>b then max:=a;  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;  fl:boolean;
begin
  fl:=false;
  if a<b then begin r:=a;a:=b;b:=r; fl:=true; 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;
    if not fl then begin d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt; end else
         begin d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=y;tt.p3:=x; tt1:=@tt; end;
   evkl:=tt1;
end;

                function phi(a,b:double):double; label 222;var p:double;
                begin
                  if (a>0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;
                  if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;
                  if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;
                  if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;
                  if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;
                  222: phi:=p;
                end;

                function nod(a,b:int64):int64; var p,t:int64;
                begin
                  a:=abs(a); b:=abs(b);
                  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 nok(a,b:int64):int64;
                begin  nok:=(a*b) div nod(a,b);  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;

                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;

                procedure udal(ii:longint);
                begin  next[prev[ii]]:=next[ii];prev[next[ii]]:=prev[ii];  end;

                function nomerr(gr:int64):int64;

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

                    end;
                  { writeln(' cc= ',cc);
                  } cc:=max(cc-3,0);
                   repeat inc(cc) until y[cc]>=gr;
                   if y[cc]=gr then fl:=true else fl:=false;
                   { if fl then nomerr:=a1[cc] else nomerr:=-1000;}
                   nomerr:=cc;
                end;

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

                 pprost:=fl;

                end;

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

                end;

 function fff(start,finish,numstr:int64):int64;
var i,j:longint; left,right,q,qq,ans,ot:int64;
begin
   left:=xleft[numstr]; right:=xright[numstr];
   ans:=besk;
   ans:=min(ans,abs(start-left)+abs(left-right)+abs(right-finish));
   ans:=min(ans,abs(start-right)+abs(left-right)+abs(left-finish));

  fff:=ans;
end;

          begin

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

         read(n);
      for i:=1 to n do read(a[i]);
      for i:=1 to n do zan[a[i]]:=true;
      pos:=0;
 2:    repeat inc(pos) until zan[pos]or(pos>1000);
     if pos<=1000 then
       begin
         { writeln('pos= ',pos);
         }  inc(ot);
          t:=1000 div pos;
          for i:=1 to t do zan[i*pos]:=false;

       end;
      if pos<=1000 then goto 2;

       writeln(ot);

      1: close (output);
    end.

//¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦//

const fi='';
      fo='';
var f:text;
    n,i,kq,j:longint;
    a:array[1..100000]of longint;
    b:array[1..100000]of boolean;
function snt(g:longint):boolean;
var i:longint;
begin
  if g<2 then exit(false);
  for i:=2 to trunc(sqrt(g)) do
    if g mod i=0 then exit(false);
  exit(true);
end;
begin
  assign(f,fi); reset(f);
  readln(f,n); kq:=0;
  fillchar(b,sizeof(b),false);
  for i:=1 to n do
    read(f,a[i]);
  close(f);
  assign(f,fo); rewrite(f);
  for i:=1 to n do
    if(snt(a[i])=true) then
     if b[a[i]]=false then
      begin
        inc(kq);
        b[a[i]]:=true;
      end
     else
    else
      for j:=2 to trunc(sqrt(a[i])) do
        if a[i] mod j=0 then
          if b[j]=false then
            begin
              b[j]:=true;
              inc(kq);
              break;
            end
          else break;
  writeln(f,kq);
  close(f);
end.

//¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦//
{                        ..sSs$$$$$$b.
                       .$$$$$$$$$$$$$$$.
                    .$$$$$$$$$$$$$$$$$$$$$b.
                  .$$$$$$$$$$$$$$$$$$$$$$$$$
                 $$$$$$$$$$$$$$$$$S'   `$$$$
                 $$$$$$$$$$$$$$S'        $$$
                 $$$$$$$$$$$$$'          `$$.
                 `$$$$$$$$$$$$$           `$$$.
                   `$$$$$$$$$'       .s$$$ $$ $
                     $$$$$$$$$.sSs .s$$s"   s s
                      $$$$$$$$$$$$           $P
                      `$$$$$$$$$$$s          $
                        $$$$$$$$$$$.    ",
                        `$$$$$$$$$$sS$
        s$$$.            `$$$$$$$$$$$$.s"'   .$.
        $$$$$.              `$$$$$$$$$$.    .$$$Ss.s$s.
         $$$$$.              `$$$$$$$$$P   .$$$$$$$$$$$$.
         $$$$$$.               `$$$$$$$' .$$$$$$$$$$$$$$$$.
         `$$$$$$.                 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$s.
           $$$$$$.                `$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$s.
         .s$$$$$$$.                 `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.
         s  $$$$$$$.                .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.
         `$$$$$$$$$$.             .$$$' $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.
          `$$$$$$$$$$.           s$'   $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.
          $$$$$$$$$$$$e         $$$     `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
        .' $$$$$$$$$$7         $$$$       `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       "   `$$$$$$$$7         $$$$$       .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$Ss..$$$$$$$7        $$$$$$$    .s$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$        $$$$$$$$ .s$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
        $$$$$$$$$$$     .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      .$$$$$$$$$$$$$   .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$$$$$$$$$$$$$  .$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$$$$$$$$$$$$$ .$$$$$$$$$$$' `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$$$$$$$$$$$$$ $$$$$$$$$$$$   `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$$$$$$$$$$$$$$$$$$$$$$$$$$    `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      `$$$$$$$$$$$$$$$$$$$$$$$$$$     `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$.     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       `$$$$$$$$$$$$$$$$$$$$$$$$$$     `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
         $$$$$$$$$$$$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
          $$$$$$$$$$$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
           $$$$$$$$$$ $$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
            $$$$$$$$$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
             $$$$$$$$$$$$$$$$$$$$'      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
             `$$$$$$$$$$$$$$$$$$$       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
              `$$$$$$$$$$$$$$$$$$.      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
               `$$$$$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                 $$$$$$$$$$$$$$$$$.     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                  `$$$$$$$$$$$$$$$$     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                    $$$$$$$$$$$$$$$     `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                    $$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$}

//¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦//

const fi='';
      fo='';
var f:text;
    n,i,kq,j:longint;
    a:array[1..100000]of longint;
    b:array[1..100000]of boolean;
function snt(g:longint):boolean;
var i:longint;
begin
  if g<2 then exit(false);
  for i:=2 to trunc(sqrt(g)) do
    if g mod i=0 then exit(false);
  exit(true);
end;
begin
  assign(f,fi); reset(f);
  readln(f,n); kq:=0;
  fillchar(b,sizeof(b),false);
  for i:=1 to n do
    read(f,a[i]);
  close(f);
  assign(f,fo); rewrite(f);
  for i:=1 to n do
    if(snt(a[i])=true) then
     if b[a[i]]=false then
      begin
        inc(kq);
        b[a[i]]:=true;
      end
     else
    else
      for j:=2 to trunc(sqrt(a[i])) do
        if a[i] mod j=0 then
          if (b[j]=false) and (b[a[i] div j]=false) then
            begin
              b[j]:=true;
              inc(kq);
              break;
            end
          else break;
  writeln(f,kq);
  close(f);
end.

//¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦//
{                        ..sSs$$$$$$b.
                       .$$$$$$$$$$$$$$$.
                    .$$$$$$$$$$$$$$$$$$$$$b.
                  .$$$$$$$$$$$$$$$$$$$$$$$$$
                 $$$$$$$$$$$$$$$$$S'   `$$$$
                 $$$$$$$$$$$$$$S'        $$$
                 $$$$$$$$$$$$$'          `$$.
                 `$$$$$$$$$$$$$           `$$$.
                   `$$$$$$$$$'       .s$$$ $$ $
                     $$$$$$$$$.sSs .s$$s"   s s
                      $$$$$$$$$$$$           $P
                      `$$$$$$$$$$$s          $
                        $$$$$$$$$$$.    ",
                        `$$$$$$$$$$sS$
        s$$$.            `$$$$$$$$$$$$.s"'   .$.
        $$$$$.              `$$$$$$$$$$.    .$$$Ss.s$s.
         $$$$$.              `$$$$$$$$$P   .$$$$$$$$$$$$.
         $$$$$$.               `$$$$$$$' .$$$$$$$$$$$$$$$$.
         `$$$$$$.                 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$s.
           $$$$$$.                `$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$s.
         .s$$$$$$$.                 `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.
         s  $$$$$$$.                .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.
         `$$$$$$$$$$.             .$$$' $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.
          `$$$$$$$$$$.           s$'   $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.
          $$$$$$$$$$$$e         $$$     `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
        .' $$$$$$$$$$7         $$$$       `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       "   `$$$$$$$$7         $$$$$       .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$Ss..$$$$$$$7        $$$$$$$    .s$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$        $$$$$$$$ .s$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
        $$$$$$$$$$$     .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      .$$$$$$$$$$$$$   .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$$$$$$$$$$$$$  .$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$$$$$$$$$$$$$ .$$$$$$$$$$$' `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$$$$$$$$$$$$$ $$$$$$$$$$$$   `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      $$$$$$$$$$$$$$$$$$$$$$$$$$$    `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
      `$$$$$$$$$$$$$$$$$$$$$$$$$$     `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       $$$$$$$$$$$$$$$$$$$$$$$$$$.     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
       `$$$$$$$$$$$$$$$$$$$$$$$$$$     `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
         $$$$$$$$$$$$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
          $$$$$$$$$$$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
           $$$$$$$$$$ $$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
            $$$$$$$$$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
             $$$$$$$$$$$$$$$$$$$$'      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
             `$$$$$$$$$$$$$$$$$$$       $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
              `$$$$$$$$$$$$$$$$$$.      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
               `$$$$$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                 $$$$$$$$$$$$$$$$$.     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                  `$$$$$$$$$$$$$$$$     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                    $$$$$$$$$$$$$$$     `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
                    $$$$$$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$}

type mang=array[1..10000] of byte;
var dem,n,i,j,a1,k:shortint;
    prime,a:mang;
procedure qsort(d,c:longint; var a:mang);
var  i,j:longint;
      tam,k:int64;
begin
  if(d>c) then  exit;
  i:=d;
  j:=c;
  k:=a[(i+j) div 2];
  repeat
    while (a[i]<k) do i:=i+1;
    while (a[j]>k) do j:=j-1;
    if (i<=j) then
      begin
       tam:=a[i];
       a[i]:= a[j];
       a[j]:=tam;
       i:=i+1;
       j:=j-1;
      end;
   until i>j;
   if(d<j) then qsort(d,j,a);
   if(i<c) then qsort(i,c,a);
end;
begin
    readln(n);
    for i := 1 to n do readln(a[i]);
    qsort(1,n,a);
    for i:=1 to n do if a[i]<>0 then
    begin
        for j := i+1 to n do if a[j] mod a[i]=0 then a[j]:=0;
    end;
    for i := 1 to n do if a[i]<>0 then inc(dem);
    writeln(dem);
    readln;
end.

var dem,n,i,a,t2,t3,t5,t7:shortint;
begin
    readln(n);
    for i := 1 to n do
    begin
        readln(a);
        if {(a mod 2 = 0) or }(((a mod 2=0) and (a mod 5=0)) or ((a mod 2=0) and (a mod 3=0)) or ((a mod 2=0) and (a mod 7=0))) then inc(t2)
        else if (a mod 3=0) and (a mod 2<>0) then inc(t3)
        else if (a mod 5=0) and (a mod 2<>0) then inc(t5)
        else if (a mod 7=0) and (a mod 2<>0) then inc(t7)
    end;
    if t2<>0 then t2 := t2 div t2;
    if t3<>0 then t3 := t3 div t3;
    if t5<>0 then t5 := t5 div t5;
    if t7<>0 then t7 := t7 div t7;
    writeln(t2+t3+t5+t7);
    readln;
end.

var dem,n,i,snt,a,t2,t3,t5,t7:shortint;
begin
    snt := 2;
    readln(n);
    for i := 1 to n do
    begin
        readln(a);
        if ((a mod 2=0) and (a mod 5=0)) or ((a mod 2=0) and (a mod 3=0)) or ((a mod 2=0) and (a mod 7=0)) then inc(t2)
        else if (a mod 3=0) and (a mod 2<>0) then inc(t3)
        else if (a mod 5=0) and (a mod 2<>0) then inc(t5)
        else if (a mod 7=0) and (a mod 2<>0) then inc(t7)
    end;
    if t2<>0 then t2 := t2 div t2;
    if t3<>0 then t3 := t3 div t3;
    if t5<>0 then t5 := t5 div t5;
    if t7<>0 then t7 := t7 div t7;
    writeln(t2+t3+t5+t7);
    readln;
end.

var dem,n,i,a,t2,t3,t5,t7:shortint;
begin
    readln(n);
    for i := 1 to n do
    begin
        read(a);
        if {(a mod 2 = 0) or }(((a mod 2=0) and (a mod 5=0)) or ((a mod 2=0) and (a mod 3=0)) or ((a mod 2=0) and (a mod 7=0))) then inc(t2)
        else if (a mod 3=0) and (a mod 2<>0) then inc(t3)
        else if (a mod 5=0) and (a mod 2<>0) then inc(t5)
        else if (a mod 7=0) and (a mod 2<>0) then inc(t7)
    end;
    if t2<>0 then t2 := t2 div t2;
    if t3<>0 then t3 := t3 div t3;
    if t5<>0 then t5 := t5 div t5;
    if t7<>0 then t7 := t7 div t7;
    writeln(t2+t3+t5+t7);
    readln;
end.

var dem,n,i,snt,a,t2,t3,t5,t7:shortint;
begin
    snt := 2;
    readln(n);
    for i := 1 to n do
    begin
        read(a);
        if (a mod 2 = 0) or (((a mod 2=0) and (a mod 5=0)) or ((a mod 2=0) and (a mod 3=0)) or ((a mod 2=0) and (a mod 7=0))) then inc(t2)
        else if (a mod 3=0) and (a mod 2<>0) then inc(t3)
        else if (a mod 5=0) and (a mod 2<>0) then inc(t5)
        else if (a mod 7=0) and (a mod 2<>0) then inc(t7)
    end;
    if t2<>0 then t2 := t2 div t2;
    if t3<>0 then t3 := t3 div t3;
    if t5<>0 then t5 := t5 div t5;
    if t7<>0 then t7 := t7 div t7;
    writeln(t2+t3+t5+t7);
    readln;
end.

Var i,n,j,kq,ktc:Longint;
A:array[1..100]of Longint;
kt:array[1..100]of Boolean;

Procedure Pt;
Begin
j:=2;
While A[i] > 1 do
    Begin
    If A[i] mod j = 0 then
        Begin
        Kt[j]:=True;
        While A[i] mod j = 0 do
        A[i]:=A[i] div j;
        End;
    Inc(j);
    End;
End;

Begin
Readln(n);
For i:=1 to n do
    Begin
    Read(A[i]);
    If A[i]=1 then
        Begin
        Ktc:=1;
        Break;
        End else
    Pt;
    End;
kq:=0;
If ktc=1 then Writeln('1') else
begin
For i:=1 to n do
If kt[i]=true then inc(kq);
Writeln(kq);
End;
End.

Var i,n,j,kq,ktc:Longint;
A:array[1..100]of Longint;
kt:array[1..100]of Boolean;

Procedure Pt;
Begin
j:=2;
While A[i] > 1 do
    Begin
    If A[i] mod j = 0 then
        Begin
        Kt[j]:=True;
        While A[i] mod j = 0 do
        A[i]:=A[i] div j;
        End;
    Inc(j);
    End;
End;

Begin
Readln(n);
If n = 1 then
begin
Read(A[i]);
Writeln('1');
End else
Begin
For i:=1 to n do
    Begin
    Read(A[i]);
    If A[i]=1 then
        Begin
        Ktc:=1;
        Break;
        End else
    Pt;
    End;
kq:=0;
If ktc=1 then Writeln('1') else
begin
For i:=1 to n do
If kt[i]=true then inc(kq);
Writeln(kq);
End;
End;
End.

Var i,n,j,kq,ktc:Longint;
A:array[1..100]of Longint;
kt:array[1..100]of Boolean;

Procedure Pt;
Begin
j:=2;
While A[i] > 1 do
    Begin
    If A[i] mod j = 0 then
        Begin
        Kt[j]:=True;
        While A[i] mod j = 0 do
        A[i]:=A[i] div j;
        End;
    Inc(j);
    End;
End;

Begin
Readln(n);
For i:=1 to n do
    Begin
    Read(A[i]);
    If A[i]=1 then
        Begin
        Ktc:=1;
        Break;
        End else
    Pt;
    End;
kq:=1;
If ktc=1 then Writeln(kq) else
begin
For i:=1 to n do
If kt[i]=true then inc(kq);
Writeln(kq);
End;
End.

Var i,n,j,kq:Longint;
A:array[1..100]of Longint;
kt:array[1..100]of Boolean;

Procedure Pt;
Begin
j:=2;
While A[i] > 1 do
    Begin
    While A[i] mod j = 0 do
        Begin
        Kt[j]:=true;
        A[i]:=A[i] div j;
        End;
    Inc(j);
    End;
End;

Begin
Readln(n);
For i:=1 to n do
    Begin
    Read(A[i]);
    Pt;
    End;
kq:=0;
For i:=1 to n do
If kt[i]=true then inc(kq);
Writeln(kq);
End.

type mang = array [1..100] of longint;
var i,n,j,t,d:longint;
    a,b:mang;

procedure qsort(var a : mang);

    procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]>x do
            inc(i);
           while x>a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;

    begin
       sort(1,n);
    end;

begin
    readln(n);
    for i:=1 to n do
            read(a[i]);
    qsort(a);
    i:=1; d:=0;
    while i<n do
       begin
            while (b[i] = 1) and (i < n) do inc(i);
            if i=n then break;
            t:=i;
            b[i]:=1;
            j:=i+1;
            while j<=n do
                begin
                    if (a[t] mod a[j] = 0) and (b[j] = 0) then
                       begin
                           t:=j;
                           b[t]:=1;
                           inc(j);
                       end
                    else inc(j);
                end;
            inc(d);
            inc(i);
        end;
    writeln(d);
end.

var
n,t,x,i,k,f,j:int64;
a:array [1..100] of int64;
begin
  readln(t);
  k:=t;
  for i :=1 to t do
  begin
    read(a[i]);
    for j:=1 to i-1 do
      if (a[i] mod a[j]=0) or (a[j] mod a[i]=0) then f:=1;
    if f=1 then begin f:=0; k:=k-1; end;
  end;
  write(k);
end.

var
n,t,x,i,k,f,j:int64;
a:array [1..100] of int64;
begin
  readln(t);
  f:=0;
  k:=t;
  for i :=1 to t do
  begin
    read(a[i]);
    for j:=1 to i-1 do
      if (a[i] mod a[j]=0) or (a[j] mod a[i]=0) then f:=1;
    if f=1 then begin f:=0; k:=k-1; end;
  end;
  write(k);
end.