var
k,n,i,t:longint;
begin
     assign(input,'weighing.in'); reset(input);
     readln(t);
     for i:=1 to t do begin
         readln(n);
         k:=0;
         while n>1 do begin
         if n mod 2=0 then begin
            n:=n div 2;
            k:=k+1;
         end else if n mod 3=0 then begin
             n:=n div 3;
             k:=k+1;
         end else begin
             n:=(n-1) div 2;
             k:=k+1;
         end;
         end;
     writeln(k);
end;
end.