program mason;
var
p,i,j:longint;
ans,l:array[0..500]of longint;
f1,f2:text;
procedure acl;
var
i,j:integer;
b:array[0..499]of longint;
begin
fillchar(b,sizeof(b),0);
for i:=0 to 499 do
for j:=0 to 499-i do
b[i+j]:=b[i+j]+ans[i]*l[j];
for i:=0 to 498 do begin
b[i+1]:=b[i] div 10+b[i+1];
b[i]:=b[i]mod 10;
end;
b[499]:=b[499]mod 10;
for i:=0 to 499 do ans[i]:=b[i];
end;
procedure lcl;
var
i,j:longint;
b:array[0..499]of longint;
begin
fillchar(b,sizeof(b),0);
for i:=0 to 499 do
for j:=0 to 499-i do
b[i+j]:=b[i+j]+l[i]*l[j];
for i:=0 to 498 do begin
b[i+1]:=b[i+1]+b[i] div 10;
b[i]:=b[i]mod 10;
end;
b[499]:=b[499]mod 10;
for i:=0 to 499 do l[i]:=b[i];
end;
begin
assign(f1,'mason.in');reset(f1);
assign(f2,'mason.out');rewrite(f2);
read(f1,p);
close(f1);
writeln(f2,trunc(p*ln(2)/ln(10)+1));
fillchar(l,sizeof(l),0);
fillchar(ans,sizeof(ans),0);
l[0]:=2;ans[0]:=1;
while p<>0 do begin
if p mod 2=1 then
acl;
p:=p div 2;
lcl;
end;
i:=0;
while ans[i]=0 do inc(i);
dec(ans[i]);
for j:=0 to i-1 do ans[j]:=9;
for i:=499 downto 0 do begin
write(f2,ans[i]);
if i mod 50=0 then writeln(f2);
end;
close(f2);
end.