        const
                tfi='DATA4.txt';
                tfo='OUT4.txt';
                maxn=11;
        var
                m,n     :       longint;
                c       :       array[0..maxn] of longint;
                sl      :       array[0..maxn] of longint;
                kq      :       longint;
        procedure doicho(i,j:longint);
            var
                tg      :longint;
            begin
                tg:=c[i];c[i]:=c[j];c[j]:=tg;
            end;
        procedure nhap;
            var
                i,j     :       longint;
            begin
                readln(m);
                readln(n);
                for i:=1 to n do
                    readln(c[i]);
                for i:=1 to n-1 do
                   for j:=i+1 to n do
                      if c[i]<c[j] then doicho(i,j);
                fillchar(sl,sizeof(sl),0);
            end;
        procedure duyet(k,b,ii:longint);
            var
                i,j     :       longint;
            begin
                if b>kq then exit;
                if k=0 then
                    begin
                        kq:=b;
                        exit;
                    end;
                j:=0;
                if ii>n then exit;
                while k-j*c[ii]>=0 do
                 begin
                    duyet(k-j*c[ii],b+j,ii+1);
                    inc(j);
                 end;
            end;
        procedure xuly;
            var
                i,j,l,r,x     :       longint;
            begin
                kq:=m div c[n];
                duyet(m,0,1);
            end;
        begin
              assign(input,tfi);reset(input);
              assign(output,tfo);rewrite(output);
              while not eof do
                  begin
                      nhap;
                      xuly;
                      writeln(kq);
                  end;
              close(input);
              close(output);
        end.
