uses wincrt;

function max(x,y:integer):integer;
  begin
    if x>y then max := x else max := y;
  end;

procedure getfrac(fraction:string; var n,d:longint);
  var i,j:integer;
  begin
    i := pos('/',fraction);
    val(copy(fraction,1,i-1),n,j);
    val(copy(fraction,i+1,length(fraction)-1),d,j);
  end;

function pwr10(x:integer):longint;
  var i:integer; return:longint;
  begin
    return := 1;
    for i := 1 to x do
      return := return * 10;
    pwr10 := return;
  end;

function getdigit(number:longint; digit:integer):integer;
  begin
    if digit < 0 then
      getdigit := 0
    else
      getdigit := trunc((number - trunc(number/pwr10(digit+1))*pwr10(digit+1))/pwr10(digit));
  end;

type premainder = ^tremainder;
     tremainder = record
       remainder:longint;
       next: premainder;
     end;

procedure addremainder(n:longint; var r:premainder);
  var r2: premainder;
  begin
    r2 := new(premainder);
    r2^.remainder := n;
    r2^.next := r;
    r := r2;
  end;

function whichremainder(n:longint; r:premainder):integer;
  var count:integer;
  begin
    count := 0;
    whichremainder := 0;
    while r<>nil do
      begin
        inc(count);
        if (n=r^.remainder) then whichremainder := count;
        r := r^.next;
      end;
  end;

procedure killremainders(var r:premainder);
  var r2:premainder;
  begin
    while r<>nil do
      begin
        r2 := r^.next;
        dispose(r);
        r := r2;
      end;
  end;

function divide(n,d:longint):string;
  var return,digit:string;
      remainder:longint;
      curdigit,lastremainder:integer;
      rems:premainder;
      warning:boolean;
  begin
    return := '';
    curdigit := max(0,trunc(ln(n/d)/ln(10)));
    remainder := trunc(n/pwr10(curdigit));
    rems := nil;
    repeat
      str(remainder div d,digit); return := return + digit;
      if curdigit=0 then return := return + '.';
      dec(curdigit);
      remainder := (remainder mod d)*10+getdigit(n,curdigit);
      lastremainder := whichremainder(remainder,rems);
      if curdigit<0 then addremainder(remainder,rems);
      warning := (length(return)>=255);
    until warning or ((curdigit<0) and ((lastremainder<>0) or (remainder=0)));
    killremainders(rems);
    if remainder<>0 then
      begin
        insert('(',return,length(return)-lastremainder+1);
        return := return + ')';
      end;
    divide := return;
  end;

var frac:string;
    n,d:longint;

begin
  write('Enter a fraction:  '); readln(frac);
  getfrac(frac,n,d);
  writeln(divide(n,d));
end.