{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
program periodP;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var p:array [1..1000] of byte;
    d,st,j,n,i,a,b,k,t:longint;
     m:int64;
     code:integer;
     s,s1,ch:string;
function NOD(a,b:longint):longint;
 begin
  if (a=0)or(b=0) then result:=a+b
  else if a>b then result:=nod(a mod b,b)
              else result:=nod(a,b mod a);
 end;
 begin
 reset(input,'input.txt');
 rewrite(output,'output.txt');
 read(a,b);//���� n
   str(b,s1);
   s:='';
   m:=b;k:=0;st:=1;
   while b>0 do    //���������� ���� � �����������
    begin
     inc(k);
     b:=b div 10;
    end;
    for i:=1 to k do  // 10 � �-� �������
      st:=st*10;
      n:=st-a;
      d:=nod(m,n);
      n:= n div d;
      m:=m div d;
      m:=m*10;
      p[1]:=m div n;
      m:=m mod n;
      t:=1;
 for i:=1 to k-1 do
 begin
  m:=10*m;
   m:=m mod n;
 end;
 repeat
  m:=10*m;
  t:=t+1;
  p[t]:=m div n;
  str(p[t],ch);
  s:=s+ch;
  if pos(s1,s)>0 then break;
  m:=m mod n;
 until pos(s1,s)>0;
 delete(s,pos(s1,s),k);
  write(s1,s);
  close(output);

end.


